﻿function sdnClick(key) {
	var src = (new Date()).getTime();
	(new Image()).src = 'http://tj.kugou.com/front/link.php?id=' + key + '&url=&t=' + src
}
var KGMO = {};
KGMO.global = {
	bannerData: [],
	isShowSlider: true,
	slider: null,
	player: null,
	curTab: 0,
	timeout: 10000,
	progressSt: null,
	uiLRC: null,
	linksIndex: [],
	curFontSize: 16,
	isCover: true,
	newslist: {
		data: [],
		isOpenSlider: true,
		isOver: false,
		isLoad: false,
		pageSize: 20,
		curPage: 1
	},
	discover: {
		isInit: false
	},
	banglist: {
		detail: {
			data: [],
			cid: null,
			isOver: false,
			isLoad: false,
			pageSize: 20,
			curPage: 1
		},
		data: [],
		isOver: false,
		isLoad: false,
		pageSize: 1000,
		outOpen: false,
		curPage: 1
	},
	playlist: {
		detail: {
			data: [],
			sid: null,
			ctype: 1,
			isOver: false,
			isLoad: false,
			pageSize: 20,
			curPage: 1
		},
		data: [],
		isOver: false,
		isLoad: false,
		pageSize: 8,
		curPage: 1
	},
	fmlist: {
		detail: {
			data: [],
			fmid: null,
			isLoad: false,
			pageSize: 10,
			offset: ""
		},
		data: [],
		isOver: false,
		isLoad: false,
		pageSize: 10,
		curPage: 1
	},
	ringlist: {
		detail: {
			data: [],
			isOver: false,
			isLoad: false,
			pageSize: 80,
			curPage: 1
		},
		musicId: null,
		sendMusicId: null,
		mobile: null,
		data: [],
		curPage: 1
	},
	search: {
		detail: {
			data: [],
			keyword: '',
			isLoad: false,
			pageSize: 10,
			curPage: 1
		},
		tags: {
			count: 10
		},
		isInit: false
	},
	collect: {
		detail: {
			data: [],
			cid: null,
			isOver: false,
			isLoad: false,
			pageSize: 20,
			curPage: 1
		},
		data: [],
		isInit: false
	},
	singerlist: {
		detail: {
			data: [],
			singerid: null,
			isOver: false,
			isLoad: false,
			pageSize: 20,
			curPage: 1
		},
		tid: null,
		data: [],
		isOver: false,
		isLoad: false,
		curPage: 1,
		pagesize: 10,
		index: 0,
		typeData: [],
		isInit: false
	}
};
KGMO.url = {
	getSongInfo: "http://m.kugou.com/app/i/getSongInfo.php",
	getSingerHead: "http://m.kugou.com/app/i/getSingerHead_new.php",
	defaultSingerHead: "http://m.kugou.com/static/images/index2013/default.png",
	defaultPic: "http://m.kugou.com/static/images/index2013/default_ban.jpg",
	loadingImg: "http://m.kugou.com/static/images/index2013/loading.gif",
	banner: "http://mobilecdn.kugou.com/new/app/i/tool.php",
	specialUrl: "http://mobilecdn.kugou.com/new/app/i/quku.php",
	specialInfo: "http://mobilecdn.kugou.com/new/app/i/quku.php",
	fmUrl: "http://m.kugou.com/app/i/fmList.php",
	fmSongsUrl: "http://m.kugou.com/app/i/fmSongs.php",
	listurl: "http://mobilecdn.kugou.com/new/app/i/yueku.php",
	singerClassUrl: "http://mobilecdn.kugou.com/new/app/i/singer.php",
	singerInfoUrl: "http://mobilecdn.kugou.com/api/v3/singer/info",
	singerSongsList: "http://mobilecdn.kugou.com/api/v3/singer/song",
	searchTagsUrl: "http://mobilecdn.kugou.com/api/v3/search/hot",
	searchUrl: "http://mobilecdn.kugou.com/api/v3/search/song",
	lrc: "http://m.kugou.com/app/i/krc.php",
	loginAndRegUrl: "http://m.kugou.com/app/i/loginAndReg.php",
	collectUrl: "http://mobileservice.kugou.com/new/app/i/html5.php",
	ringUrl: "http://m.kugou.com/app/i/getcrbt.php"
};
KGMO.util = {
	getBytes: function(o) {
		var bytes = 0;
		for (var i = 0; i < o.str.length; i++) {
			if (o.str.charCodeAt(i) > 256) {
				bytes += 2
			} else {
				bytes += 1
			}
		}
		return bytes
	},
	Cookie: {
		read: function(name, key) {
			var cookieValue = "",
				search = name + "=",
				arr = [],
				o = {};
			if (document.cookie.length > 0) {
				offset = document.cookie.indexOf(search);
				if (offset != -1) {
					offset += search.length;
					end = document.cookie.indexOf(";", offset);
					if (end == -1) {
						end = document.cookie.length
					}
					cookieValue = document.cookie.substring(offset, end)
				}
			}
			if (key) {
				var a = cookieValue.split("&");
				for (var i = 0, l = a.length; i < l; i++) {
					var k = a[i].split("=");
					o[k[0]] = k[1]
				}
				return o[key]
			}
			return cookieValue
		},
		remove: function(o) {
			var cookie = o.name + "=";
			if (o.path) cookie += '; path=' + o.path;
			if (o.domain) cookie += ';domain=' + o.domain;
			cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
			document.cookie = cookie
		}
	},
	getRequest: function() {
		var url = location.search;
		var theRequest = new Object();
		if (url.indexOf("?") != -1) {
			var str = url.substr(1);
			strs = str.split("&");
			for (var i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1]
			}
		}
		return theRequest
	},
	isOnline: function() {
		if (navigator.onLine) {
			return true
		}
		return false
	},
	randomSort: function() {
		return Math.random() > 0.5 ? -1 : 1
	},
	queryString: function(item) {
		var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
		return svalue ? svalue[1] : svalue
	},
	getSingerImg: function(o) {
		var img = "about:blank";
		if (o.img) {
			img = o.img.replace(/softhead\//, "softhead/" + o.size + "/")
		}
		return img
	},
	getFmImg: function(o) {
		o.w = o.w || 145;
		if (o.img) {
			return "http://imge.kugou.com/fmlogo/" + o.w + "/" + o.img
		} else {
			return "about:blank"
		}
	},
	getBangImg: function(o) {
		var size = o.size || "200";
		if (o.img) {
			return o.img.replace(/\{size\}/gi, size)
		} else {
			return KGMO.url.defaultSingerHead
		}
	},
	addZero: function(n) {
		return n.toString().length <= 1 ? "0" + n : n
	},
	isCanPlayAudio: function() {
		if ( !! (document.createElement('audio').canPlayType("audio/mpeg"))) {
			return true
		} else {
			return false
		}
	},
	isIOS: function() {
		if (navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
			return true
		} else {
			return false
		}
	},
	scrollToTop: function() {
		document.body.scrollTop = 0
	},
	isScrollBot: function() {
		if (($(window).scrollTop() + $(window).height()) >= ($(document).height() - 20)) {
			return true
		}
		return false
	}
};
KGMO.funs = {
	setSingerClass: function() {
		var _this = KGMO,
			_mod_singer = $("#mod_singer"),
			html = [];
		$.ajax({
			type: 'get',
			url: _this.url.singerClassUrl,
			dataType: 'jsonp',
			data: {
				outputtype: "jsonp",
				cmd: 100
			},
			success: function(res) {
				var data = res["data"];
				_this.global.singerlist.typeData = data;
				if (res && res["status"] == 1) {
					for (i = 0; i < data.length; i++) {
						if (i % 3 === 0) {
							html.push('<div class="list">')
						}
						html.push('<div class="item" onclick="KGMO.api.showSingerTypeList({tid:' + data[i]['classid'] + '})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + data[i]['imgurl'] + '" onerror="this.onerror=null;this.src=\'' + _this.url.defaultSingerHead + '\'" alt=""/></a><h5><a href="javascript:;">' + data[i]['classname'] + '</a></h5></div>');
						if (i % 3 === 2) {
							html.push('</div>')
						}
					}
					_mod_singer.html(html.join(""));
					_mod_singer.find("img").each(function(i, v) {
						$(this).attr("src", $(this).attr("data-url"))
					});
					_this.funs.hideLoading()
				}
			},
			error: function(res) {}
		})
	},
	optMyCollect: function(o) {
		var _this = KGMO,
			json = {},
			operate = o.operate || "-1",
			loadData = function(_o) {
				$.ajax({
					type: 'get',
					url: _this.url.collectUrl,
					dataType: 'jsonp',
					data: _o.metadata,
					success: function(res) {
						var html = [],
							data = [],
							i = 0,
							l = 0,
							num = 0;
						if (res && res["status"] == 1) {
							data = res["data"];
							if (_o.cmd == 101) {
								_this.global.collect.data = data;
								for (i = 0, l = data.length; i < l; i++) {
									num += Number(data[i]["listfilecount"]);
									html.push('<li data-id="' + data[i]["listid"] + '" onclick="KGMO.api.showCollectList({id:\'' + data[i]["listid"] + '\'})"><div class="ico_star"><i></i></div><span>' + data[i]["listname"] + '</span><div class="count"><em>' + data[i]["listfilecount"] + '</em>首曲目</div><div class="btn_more"><i></i></div></li>')
								}
								$("#mod_collect").find(".collect_nums span").html(num);
								$("#collectlist").html(html.join(""));
								_this.funs.hideLoading()
							} else if (_o.cmd == 102) {
								data = _this.funs.formatCollectSongs({
									songs: data
								});
								_this.global.collect.detail.data = data;
								for (i = 0, l = data.length; i < l; i++) {
									html.push('<li><a href="javascript:;" idx="' + i + '" onclick="KGMO.api.playRankSong({idx : ' + i + ',type : 300})"><em>' + (i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})"><i></i></div></li>')
								}
								if (html.length < 1) {
									html.push('<li><span class="nosongs">该收藏列表还没有添加任何歌曲哦！</span></li>')
								}
								$("#collectdetail").html(html.join("")).show()
							} else if (_o.cmd == 103) {
								if (_o.operate == 2) {
									alert("删除成功")
								} else if (_o.operate == 3) {
									alert("重命名成功")
								} else if (_o.operate == 1) {
									alert("新增列表成功")
								}
							}
						}
					},
					error: function(res) {}
				})
			};
		if (_this.user.info.kugouid > 0) {
			if (o.cmd == 101) {
				_this.funs.showLoading();
				json = {
					cmd: 101,
					uid: _this.user.info.kugouid,
					outputtype: "jsonp",
					"d": Math.random()
				}
			} else if (o.cmd == 102) {
				json = {
					cmd: 102,
					listid: _this.global.collect.detail.cid,
					uid: _this.user.info.kugouid,
					outputtype: "jsonp",
					"d": Math.random()
				}
			} else if (o.cmd == 103) {
				var orderweight;
				for (var i = 0; i < _this.global.collect.data.length; i++) {
					if (_this.global.collect.detail.cid == _this.global.collect.data[i]["listid"]) {
						orderweight = _this.global.collect.data[i]["orderweight"];
						break
					}
				}
				if (operate == 2) {
					json = {
						cmd: 103,
						listid: _this.global.collect.detail.cid,
						operate: 2,
						orderweight: orderweight,
						uid: _this.user.info.kugouid,
						outputtype: "jsonp",
						"d": Math.random()
					}
				} else if (operate == 3) {
					json = {
						cmd: 103,
						listid: _this.global.collect.detail.cid,
						listname: "%E9%87%8D%E5%91%BD%E5%90%8D%E5%88%97%E8%A1%A8",
						operate: 3,
						orderweight: orderweight,
						uid: _this.user.info.kugouid,
						outputtype: "jsonp",
						"d": Math.random()
					}
				} else if (operate == 1) {
					json = {
						cmd: 103,
						listid: "",
						listname: "%E9%87%8D%E5%91%BD%E5%90%8D%E5%88%97%E8%A1%A8",
						operate: 1,
						orderweight: 5,
						uid: _this.user.info.kugouid,
						outputtype: "jsonp",
						"d": Math.random()
					}
				}
			}
			loadData({
				cmd: o.cmd,
				operate: operate,
				metadata: json
			})
		}
	},
	formatCollectSongs: function(o) {
		var tmpData = [];
		tmpData = o.songs;
		for (var i = 0; i < tmpData.length; i++) {
			tmpData[i]["timelength"] = Math.ceil(tmpData[i]["timelength"] / 1000)
		}
		return tmpData
	},
	formatRingSongs: function(o) {
		var tmpData = [];
		var filename = "";
		for (var i = 0; i < o.songs.length; i++) {
			if (o.songs[i]['singerName'] !== "") {
				filename = o.songs[i]['singerName'] + " - " + o.songs[i]['songName']
			} else {
				filename = o.songs[i]['songName']
			}
			tmpData[i] = {
				filename: filename,
				id: o.songs[i]["musicid"],
				songurl: o.songs[i]['crbtListenDir'],
				price: o.songs[i]["price"],
				data: o.songs[i]["crbtValidity"],
				ext: null,
				bitrate: null,
				hash: null,
				size: null,
				timelength: null
			}
		}
		return tmpData
	},
	formatSingerSongs: function(o) {
		var tmpData = [];
		for (var i = 0; i < o.songs.length; i++) {
			tmpData[i] = {
				bitrate: o.songs[i]["bitrate"],
				ext: o.songs[i]["extname"],
				hash: o.songs[i]['hash'],
				filename: o.songs[i]['filename'],
				size: o.songs[i]['filesize'],
				timelength: o.songs[i]["duration"]
			}
		}
		return tmpData
	},
	formatFmSongs: function(o) {
		var tmpData = [];
		for (var i = 0; i < o.songs.length; i++) {
			tmpData[i] = {
				fmid: o.fmid,
				bitrate: o.songs[i]["bitrate"],
				ext: o.songs[i]["ext"],
				hash: o.songs[i]['hash'],
				filename: o.songs[i]['name'],
				size: o.songs[i]['size'],
				timelength: Math.ceil(o.songs[i]["time"] / 1000)
			}
		}
		return tmpData
	},
	popBase: function(o) {
		var _pop_base = $("#pop_base"),
			_pop_bg = $("#pop_bg"),
			sh = $("html").height(),
			ch = $(window).height(),
			st = $(window).scrollTop(),
			wsh = window.screen.height;
		switch (o.type) {
		case "forget":
			_pop_base.find(".html_pop_forget").show();
			break;
		default:
			break
		}
		_pop_base.css({
			"top": parseInt(ch / 2, 10) + st + "px",
			"z-index": 9999
		}).show();
		_pop_bg.css("height", sh + wsh + "px").addClass("pop_bg_show").show()
	},
	popDown: function() {
		var _pop_down = $("#pop_down"),
			_pop_bg = $("#pop_bg"),
			sh = $("html").height(),
			ch = $(window).height(),
			st = $(window).scrollTop();
		_pop_down.css({
			"top": parseInt(ch / 2, 10) + st + "px",
			"z-index": 9999
		}).show();
		_pop_bg.css("height", sh + "px").addClass("pop_bg_show").show()
	},
	addLinksIndex: function(o) {
		if (o.str !== "" && KGMO.global.linksIndex[KGMO.global.linksIndex.length - 1] != o.str) {
			KGMO.global.linksIndex[KGMO.global.linksIndex.length] = o.str
		}
	},
	delAndBackLinksIndex: function() {
		var index = 0;
		if (KGMO.global.linksIndex.length > 0) {
			KGMO.global.linksIndex.length--;
			index = KGMO.global.linksIndex[KGMO.global.linksIndex.length - 1]
		}
		return index
	},
	goBack: function() {
		var tab = KGMO.funs.delAndBackLinksIndex();
		KGMO.funs.changeTab({
			tab: tab,
			back: true
		})
	},
	changeTab: function(o) {
		var _this = KGMO,
			_mod_header = $("#mod_header"),
			_mod_nav = $("#mod_nav"),
			_mod_ban = $("#mod_ban"),
			_mod_subnav = $("#mod_subnav"),
			_mod_newslist = $("#mod_newslist"),
			_mod_discover = $("#mod_discover"),
			_mod_submain = $("#mod_submain"),
			_mod_detailmain = $("#mod_detailmain"),
			_mod_singer = $("#mod_singer"),
			_mod_search = $("#mod_search"),
			_mod_collect = $("#mod_collect"),
			_mod_ringorder = $("#mod_ringorder"),
			_mod_login = $("#mod_login"),
			_mod_mainplayer = $("#mod_mainplayer"),
			_mod_player = $("#mod_player");
		if (o.tab != _this.global.curTab) {
			_this.funs.hideLoading()
		}
		$(".loadstatus").hide();
		_this.util.scrollToTop();
		_this.global.curTab = o.tab;
		_mod_search.hide();
		if (!o.back) {
			_this.funs.addLinksIndex({
				str: _this.global.curTab
			})
		}
		switch (_this.global.curTab) {
		case 1:
			_mod_header.find(".btn_back").hide();
			_mod_header.find(".tit").hide();
			_mod_ban.hide();
			_mod_newslist.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_singer.hide();
			_mod_collect.hide();
			_mod_login.hide();
			_mod_ringorder.hide();
			_mod_mainplayer.hide();
			_mod_search.hide();
			_mod_singer.hide();
			_mod_header.find(".btn_back,.tit").hide();
			_mod_header.find(".logo,.btn_search").show();
			_mod_subnav.show();
			_mod_discover.show();
			_mod_nav.find("li").removeClass("cur");
			_mod_nav.show().find(".it2").addClass("cur");
			_mod_player.show();
			KGMO.funs.getIndexList();
			break;
		case 2:
			_mod_header.find(".btn_back").hide();
			_mod_header.find(".tit").hide();
			_mod_ban.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_collect.hide();
			_mod_login.hide();
			_mod_ringorder.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_mainplayer.hide();
			_mod_header.find(".btn_back,.tit").hide();
			_mod_header.find(".logo,.btn_search").show();
			_mod_nav.find("li").removeClass("cur");
			_mod_nav.show().find(".it3").addClass("cur");
			_mod_singer.show();
			_mod_player.show();
			if (!_this.global.singerlist.isInit) {
				_this.funs.showLoading();
				_this.funs.setSingerClass()
			}
			break;
		case 3:
			_mod_header.find(".btn_back").hide();
			_mod_header.find(".tit").hide();
			_mod_ban.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_ringorder.hide();
			_mod_detailmain.hide();
			_mod_mainplayer.hide();
			_mod_singer.hide();
			_mod_header.find(".btn_back,.tit").hide();
			_mod_header.find(".logo,.btn_search").show();
			_mod_nav.find("li").removeClass("cur");
			_mod_nav.show().find(".it4").addClass("cur");
			_mod_player.show();
			_this.user.checkLogin();
			if (_this.user.info.kugouid > 0) {
				_this.user.setUserInfo();
				_this.user.alreadyLogin();
				_this.funs.optMyCollect({
					cmd: 101
				})
			} else {
				_mod_collect.hide();
				$("#mlogin").hide();
				$("#mreg").hide();
				$("#nologin").show();
				_mod_login.show()
			}
			break;
		case 4:
			_mod_nav.hide();
			_mod_subnav.hide();
			_mod_ban.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_singer.hide();
			_mod_ringorder.hide();
			_mod_collect.hide();
			_mod_login.hide();
			_mod_player.hide();
			_mod_mainplayer.hide();
			_mod_header.find(".logo,.tit,.btn_search").hide();
			$("#searchtit").html("搜索");
			_mod_header.find(".btn_back,#searchtit").show();
			_mod_search.show();
			_mod_player.show();
			if (!o.keyword && !o.back) {
				if (!_this.global.search.isInit) {
					_this.funs.getSearchTag()
				}
			} else {
				if (_this.global.search.detail.keyword != o.keyword && !o.back) {
					_mod_search.find(".search_tag").hide();
					_this.global.search.detail.curPage = 1;
					_this.global.search.detail.isLoad = false;
					_this.global.search.detail.isOver = false;
					_this.global.search.detail.keyword = o.keyword;
					_this.funs.getList()
				}
			}
			break;
		case 5:
			_mod_nav.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_ringorder.hide();
			_mod_singer.hide();
			_mod_collect.hide();
			_mod_login.hide();
			_mod_player.hide();
			_mod_header.find(".logo,.tit,.btn_search").hide();
			_mod_ban.show();
			_mod_mainplayer.show();
			_mod_header.find(".btn_back,#songtitle").show();
			break;
		case 10:
		case 11:
		case 12:
		case 13:
		case 20:
			_mod_nav.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_detailmain.hide();
			_mod_singer.hide();
			_mod_collect.hide();
			_mod_login.hide();
			_mod_ringorder.hide();
			_mod_player.hide();
			_mod_mainplayer.hide();
			_mod_header.find(".logo,.tit").hide();
			_mod_submain.find(".subbanglist").hide();
			_mod_submain.find(".subplaylist").hide();
			_mod_submain.find(".subfmlist").hide();
			_mod_submain.find(".subsingerlist").hide();
			_mod_submain.find(".subringlist").hide();
			_mod_header.find(".btn_back,#tabtitle,.btn_search").show();
			_mod_ban.show();
			_mod_submain.show();
			_mod_player.show();
			if (_this.global.curTab == 10) {
				$("#tabtitle").html("排行榜");
				if (_this.global.banglist.curPage == 1) {
					KGMO.funs.getList()
				} else {
					_mod_submain.find(".subbanglist").show()
				}
			} else if (_this.global.curTab == 11) {
				$("#tabtitle").html("歌单");
				if (_this.global.playlist.curPage == 1) {
					KGMO.funs.getList()
				} else {
					_mod_submain.find(".subplaylist").show()
				}
			} else if (_this.global.curTab == 12) {
				$("#tabtitle").html("电台");
				if (_this.global.fmlist.curPage == 1) {
					KGMO.funs.getList()
				} else {
					_mod_submain.find(".subfmlist").show()
				}
			} else if (_this.global.curTab == 13) {
				$("#tabtitle").html("彩铃");
				if (_this.global.ringlist.detail.curPage == 1 && !o.back) {
					KGMO.funs.getList()
				} else {
					_mod_submain.find(".subringlist").show()
				}
			} else if (_this.global.curTab == 20) {
				if (_this.global.singerlist.tid != o.tid && !o.back) {
					_mod_submain.find(".subsingerlist").html("");
					_this.global.singerlist.curPage = 1;
					_this.global.singerlist.isLoad = false;
					_this.global.singerlist.isOver = false;
					_this.global.singerlist.tid = o.tid;
					_this.funs.setSingerInfo();
					_this.funs.getList()
				} else {
					_mod_submain.find(".subsingerlist").show()
				}
			}
			break;
		case 100:
		case 101:
		case 200:
		case 300:
			_mod_nav.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_singer.hide();
			_mod_collect.hide();
			_mod_ringorder.hide();
			_mod_login.hide();
			_mod_player.hide();
			_mod_mainplayer.hide();
			_mod_submain.hide();
			_mod_detailmain.find(".bangdetail").hide();
			_mod_detailmain.find(".playdetail").hide();
			_mod_detailmain.find(".singerdetail").hide();
			_mod_detailmain.find(".collectdetail").hide();
			_mod_header.find(".logo,.tit").hide();
			_mod_ban.show();
			_mod_player.show();
			_mod_detailmain.show();
			if (_this.global.curTab == 100) {
				_mod_header.find(".btn_back,#tabtitle,.btn_search").show();
				_mod_detailmain.find(".bangdetail").show();
				if (_this.global.banglist.detail.cid != o.cid && !o.back) {
					_mod_detailmain.find(".hd").hide();
					$("#tabtitle").html(o.name);
					$("#bangdetail").find(".detaillist").html("");
					_this.global.banglist.detail.curPage = 1;
					_this.global.banglist.detail.isLoad = false;
					_this.global.banglist.detail.isOver = false;
					_this.global.banglist.detail.cid = o.cid;
					_this.funs.getList()
				}
			} else if (_this.global.curTab == 101) {
				_mod_header.find(".btn_back,#tabtitle,.btn_search").show();
				_mod_detailmain.find(".playdetail").show();
				if ((_this.global.playlist.detail.sid != o.sid || _this.global.playlist.detail.ctype != o.ctype) && !o.back) {
					if (o.ctype) {
						_this.global.playlist.detail.ctype = o.ctype
					} else {
						_this.global.playlist.detail.ctype = 1
					}
					$("#playdetail").find(".hd").hide();
					$("#tabtitle").html("");
					$("#playdetail").find(".detaillist").html("");
					_this.global.playlist.detail.curPage = 1;
					_this.global.playlist.detail.sid = o.sid;
					_this.global.playlist.detail.isLoad = false;
					_this.global.playlist.detail.isOver = false;
					_this.funs.getList()
				} else {
					_mod_detailmain.find(".hd").show()
				}
			} else if (_this.global.curTab == 200) {
				_mod_header.find(".btn_back,.btn_search").show();
				if (_this.global.singerlist.detail.singerid != o.singerid && !o.back) {
					_this.global.singerlist.detail.singerid = o.singerid;
					_this.global.singerlist.detail.curPage = 1;
					_this.global.singerlist.detail.isLoad = false;
					_this.global.singerlist.detail.isOver = false;
					_this.global.singerlist.detail.curPage = 1;
					_this.funs.getList()
				} else {
					$("#singername").show();
					$("#singerdetail").show();
					$("#singerdetail .hd").show()
				}
			} else if (_this.global.curTab == 300) {
				_mod_header.find(".btn_back,.btn_search").show();
				if (o.cid && !o.back) {
					_this.global.collect.detail.cid = o.cid;
					for (var i = 0; i < _this.global.collect.data.length; i++) {
						if (_this.global.collect.detail.cid == _this.global.collect.data[i]["listid"]) {
							$("#searchtit").html(_this.global.collect.data[i]["listname"]).show();
							break
						}
					}
					_this.funs.optMyCollect({
						cmd: 102
					})
				} else {
					$("#searchtit").show();
					_mod_detailmain.find(".collectdetail").show()
				}
			}
			break;
		case 131:
			_this.global.ringlist.musicId = o.musicId;
			_mod_header.find(".logo").hide();
			_mod_header.find(".tit").hide();
			_mod_nav.hide();
			_mod_subnav.hide();
			_mod_newslist.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_mainplayer.hide();
			_mod_singer.hide();
			_mod_header.find(".btn_back,.tit").hide();
			_mod_ringorder.find(".step2").hide();
			$("#searchtit").html("订购");
			_mod_header.find(".btn_back,.btn_search,#searchtit").show();
			_mod_nav.find("li").removeClass("cur");
			_mod_ban.show();
			_mod_player.show();
			_mod_ringorder.find(".step1").show();
			_mod_ringorder.show();
			$("#cmcphone,#cmcmsgcode").val("");
			$("#btn_sendcmccode").removeAttr("disabled").html("获取短信验证码");
			_this.global.ringlist.musicId = o.musicId;
			_this.order.getRingInfo();
			break;
		case 0:
			_mod_header.find(".btn_back").hide();
			_mod_header.find(".tit").hide();
			_mod_ban.hide();
			_mod_subnav.hide();
			_mod_discover.hide();
			_mod_submain.hide();
			_mod_detailmain.hide();
			_mod_singer.hide();
			_mod_login.hide();
			_mod_ringorder.hide();
			_mod_collect.hide();
			_mod_search.hide();
			_mod_header.find(".btn_back,.tit").hide();
			_mod_header.find(".logo,.btn_search").show();
			_mod_mainplayer.hide();
			_mod_newslist.show();
			_mod_nav.find("li").removeClass("cur");
			_mod_nav.show().find(".it1").addClass("cur");
			_mod_player.show();
			if (_this.global.newslist.curPage == 1 && !_this.global.newslist.isOver && !_this.global.newslist.isLoad) {
				if (_this.global.newslist.isOpenSlider) {
					KGMO.funs.createSlider()
				}
				KGMO.funs.getList()
			} else {
				if (_this.global.newslist.isOpenSlider) {
					KGMO.funs.initSlider()
				}
			}
			break;
		default:
			_this.funs.goBack();
			break
		}
		$(".wrap").css("padding-top", $("#top_fixed").height() + "px")
	},
	setSingerDetail: function() {
		var _this = KGMO,
			data = _this.global.singerlist.data,
			tmp = {},
			isExist = false;
		if (!isExist) {
			$.ajax({
				type: 'get',
				url: _this.url.singerInfoUrl,
				dataType: 'jsonp',
				data: {
					format: "jsonp",
					singerid: _this.global.singerlist.detail.singerid
				},
				success: function(res) {
					if (res) {
						tmp = res["data"];
						$("#singername").html(tmp['singername']);
						$("#singerdetail").find(".hd img").attr("src", _this.util.getBangImg({
							img: tmp['imgurl'],
							size: 120
						}));
						$("#singerdetail").find(".hd p").html(tmp['intro']);
						$("#singername").show()
					}
				},
				error: function() {}
			})
		} else {
			$("#singername").html(tmp['singername']);
			$("#singerdetail").find(".hd img").attr("src", _this.util.getSingerImg({
				img: tmp['imgurl'],
				size: 120
			}));
			$("#singerdetail").find(".hd p").html(tmp['intro']);
			$("#singername").show()
		}
	},
	setSingerInfo: function() {
		var _this = KGMO;
		for (var i = 0, l = _this.global.singerlist.typeData.length; i < l; i++) {
			if (_this.global.singerlist.typeData[i]['classid'] == _this.global.singerlist.tid) {
				_this.global.singerlist.index = i;
				$("#tabtitle").html(_this.global.singerlist.typeData[i]['classname']);
				break
			}
		}
	},
	getSearchTag: function() {
		var _this = KGMO,
			_mod_search = $("#mod_search");
		_this.funs.showLoading();
		$.ajax({
			type: "get",
			url: _this.url.searchTagsUrl,
			data: {
				format: "jsonp",
				plat: 0,
				count: _this.global.search.tags.count
			},
			dataType: "jsonp",
			timeout: _this.global.timeout,
			success: function(res) {
				if (res && res["status"] == 1) {
					var data = res["data"]["info"],
						html = [];
					if (data.length > _this.global.search.tags.count) {
						data.length = _this.global.search.tags.count
					}
					for (i = 0; i < data.length; i++) {
						if (i % 2 === 0) {
							html.push('<div class="list">')
						}
						html.push('<div class="item"><a href="javascript:;" class="pic">' + data[i]['keyword'] + '</a></div>');
						if (i % 2 === 1) {
							html.push('</div>')
						}
					}
					_this.funs.hideLoading();
					_mod_search.find(".search_tag").html(html.join("")).show()
				}
				_this.global.search.isInit = true
			},
			error: function(xhr, type) {
				_this.funs.hideLoading()
			}
		})
	},
	getIndexList: function() {
		var _this = KGMO,
			loadst = null,
			module = {
				loadModuleNum: 0
			},
			_mod_discover = $("#mod_discover");
		var loadData = function(o) {
				$.ajax({
					type: "get",
					url: o.url,
					data: o.data,
					dataType: o.dataType,
					timeout: _this.global.timeout,
					success: function(res) {
						var html = [],
							i = 0,
							data = [];
						if (res && res["status"] == 1) {
							if (o.tab == "bang") {
								data = res["data"];
								_this.global.banglist.data = _this.global.banglist.data.concat(data);
								for (i = 0; i < 4; i++) {
									html.push('<li onclick="KGMO.api.showBangInfo({cid:' + data[i]['cid'] + ',name:\'' + escape(data[i]["cname"]) + '\'})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + _this.util.getBangImg({
										img: data[i]["imgurl"],
										size: 85
									}) + '" alt=""/></a><span>' + data[i]['cname'] + '</span><div class="btn_more"><i></i></div></li>')
								}
								if (html.length > 0) {
									o.dom.find("ul").html(html.join(""));
									module[o.tab] = true
								}
							} else if (o.tab == "special") {
								data = res["data"];
								for (i = 0; i < 4; i++) {
									if (i % 2 === 0) {
										html.push('<div class="list">')
									}
									html.push('<div class="item" onclick="KGMO.api.showPlayList({sid:' + data[i]['cid'] + '})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + KGMO.util.getBangImg({
										img: data[i]["imgurl"],
										size: 400
									}) + '" alt=""/><span>' + data[i]["cname"] + '</span></a></div>');
									if (i % 2 === 1) {
										html.push('</div>')
									}
								}
								if (html.length > 0) {
									o.dom.find(".listbox").html(html.join(""));
									module[o.tab] = true
								}
							} else if (o.tab == "fm") {
								data = res["data"];
								_this.global.fmlist.data = data;
								for (i = 0; i < 4; i++) {
									var tmpsong = data[i]["fmSongData"][0]["songs"][0];
									if (i % 2 === 0) {
										html.push('<div class="list">')
									}
									html.push('<div class="item" fmid="' + data[i]['fmid'] + '" onclick="KGMO.api.playFmSongs({fmid:' + data[i]['fmid'] + '})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + KGMO.util.getFmImg({
										img: data[i]["imgurl"]
									}) + '" alt=""/><span class="fmame">' + data[i]["fmname"] + '</span></a></div>');
									if (i % 2 === 1) {
										html.push('</div>')
									}
								}
								if (html.length > 0) {
									o.dom.find(".listbox").html(html.join(""));
									module[o.tab] = true
								}
							} else if (o.tab == "ring") {
								data = _this.funs.formatRingSongs({
									songs: res["list"]
								});
								_this.global.ringlist.data = data;
								if (data.length > 8) {
									data.length = 8
								}
								for (i = 0; i < data.length; i++) {
									html.push('<li><a href="javascript:;" onclick="KGMO.api.playRankSong({type:13,idx:' + i + '})" class="tit"><em>' + (i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><a href="javascript:;" onclick="KGMO.api.ringOrder({musicId:\'' + data[i]["id"] + '\'})" class="btn_buy">订购</a></li>')
								}
								if (html.length > 0) {
									o.dom.find(".listbox").html(html.join(""));
									module[o.tab] = true
								}
							}
						} else {
							module[o.tab] = false
						}
						module["loadModuleNum"]++
					},
					error: function(xhr, type) {
						module[o.tab] = false;
						module["loadModuleNum"]++
					}
				})
			};
		if (!_this.global.discover.isInit) {
			_this.funs.showLoading();
			var json = {};
			json = {
				tab: "bang",
				dataType: "jsonp",
				url: _this.url.listurl,
				dom: _mod_discover.find(".banglist"),
				data: {
					cmd: 100,
					cid: 21,
					type: 21,
					page: 1,
					pagesize: _this.global.banglist.pageSize,
					outputtype: "jsonp"
				}
			};
			loadData(json);
			json = {
				tab: "special",
				dataType: "jsonp",
				url: _this.url.specialUrl,
				dom: _mod_discover.find(".playlist"),
				data: {
					cmd: 106,
					page: 1,
					pagesize: 8,
					outputtype: "jsonp"
				}
			};
			loadData(json);
			json = {
				tab: "fm",
				dataType: "json",
				url: _this.url.fmUrl,
				dom: _mod_discover.find(".fmlist"),
				data: {
					pageindex: 1,
					pagesize: 4
				}
			};
			loadData(json);
			json = {
				tab: "ring",
				dataType: "json",
				url: _this.url.ringUrl,
				dom: _mod_discover.find(".ringlist"),
				data: {}
			};
			loadData(json);
			loadst = setInterval(function() {
				if (module["loadModuleNum"] == 4) {
					if (module["bang"]) {
						_mod_discover.find(".banglist").show()
					}
					if (module["special"]) {
						_mod_discover.find(".playlist").show()
					}
					if (module["fm"]) {
						_mod_discover.find(".fmlist").show()
					}
					if (module["ring"]) {
						_mod_discover.find(".ringlist").show()
					}
					_this.global.discover.isInit = true;
					_this.funs.hideLoading();
					_mod_discover.find("img").imglazyload({});
					clearInterval(loadst)
				}
			}, 1000)
		}
	},
	getList: function() {
		var _this = KGMO,
			i = 0,
			meta = {};
		var loadData = function(o) {
				$.ajax({
					type: o.type,
					url: o.url,
					data: o.data,
					dataType: o.dataType || 'jsonp',
					timeout: _this.global.timeout,
					success: function(res) {
						if (res && res["status"] == 1) {
							if (_this.global.curTab == 200 || _this.global.curTab == 4) {
								if (res["data"] && res["data"]["info"].length > 0) {
									_this.funs.setList({
										data: res["data"]["info"]
									})
								} else {
									o.isOver();
									o.isLoad();
									if (o.cb) {
										o.cb()
									}
								}
							} else if (_this.global.curTab == 13) {
								if (res["list"] && res["list"].length > 0) {
									_this.funs.setList({
										data: _this.funs.formatRingSongs({
											songs: res["list"]
										})
									})
								} else {
									o.isOver();
									o.isLoad();
									if (o.cb) {
										o.cb()
									}
								}
							} else {
								if (res["data"] && res["data"].length > 0) {
									_this.funs.setList({
										data: res["data"]
									})
								} else {
									o.isOver();
									o.isLoad();
									if (o.cb) {
										o.cb()
									}
								}
							}
							_this.funs.hideLoading()
						} else {
							o.isOver();
							o.isLoad()
						}
					},
					error: function(xhr, type) {
						_this.funs.hideLoading();
						if (o.err) {
							o.err()
						}
					}
				})
			};
		switch (_this.global.curTab) {
		case 0:
			if (!_this.global.newslist.isLoad && !_this.global.newslist.isOver) {
				_this.global.newslist.isLoad = true;
				if (_this.global.newslist.curPage > 1) {
					$("#mod_newslist").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					data: {
						outputtype: "jsonp",
						cmd: 106,
						plat: 0,
						page: _this.global.newslist.curPage,
						pagesize: _this.global.newslist.pageSize
					},
					url: KGMO.url.listurl,
					type: "get",
					isLoad: function() {
						_this.global.newslist.isOver = false
					},
					isOver: function() {
						_this.global.newslist.isOver = true;
						$("#mod_newslist").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.newslist.isLoad = false;
						if (_this.util.isOnline()) {
							if (_this.global.newslist.curPage == 1) {
								_this.funs.changeTab({
									tab: _this.global.curTap
								})
							} else {
								_this.funs.getList()
							}
						} else {
							$("#mod_newslist").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 10:
			if (!_this.global.banglist.isLoad && !_this.global.banglist.isOver) {
				_this.global.banglist.isLoad = true;
				if (_this.global.banglist.curPage == 1) {
					_this.funs.showLoading()
				} else {
					$("#mod_submain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					data: {
						outputtype: "jsonp",
						cmd: 100,
						cid: 21,
						type: 21,
						page: _this.global.banglist.curPage,
						pagesize: _this.global.banglist.pageSize
					},
					url: KGMO.url.listurl,
					type: "get",
					isLoad: function() {
						_this.global.banglist.isOver = false
					},
					isOver: function() {
						_this.global.banglist.isOver = true;
						$("#mod_submain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.banglist.isLoad = false;
						if (_this.util.isOnline()) {
							if (_this.global.banglist.curPage == 1) {
								_this.funs.changeTab({
									tab: _this.global.curTap
								})
							} else {
								_this.funs.getList()
							}
						} else {
							$("#mod_submain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 11:
			if (!_this.global.playlist.isLoad && !_this.global.playlist.isOver) {
				_this.global.playlist.isLoad = true;
				if (_this.global.playlist.curPage == 1) {
					_this.funs.showLoading()
				} else {
					$("#mod_submain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					data: {
						cmd: 106,
						outputtype: "jsonp",
						page: _this.global.playlist.curPage,
						pagesize: _this.global.playlist.pageSize
					},
					url: KGMO.url.specialUrl,
					type: "get",
					isLoad: function() {
						_this.global.playlist.isOver = false
					},
					isOver: function() {
						_this.global.playlist.isOver = true;
						$("#mod_submain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.playlist.isLoad = false;
						if (_this.util.isOnline()) {
							if (_this.global.playlist.curPage == 1) {
								_this.funs.changeTab({
									tab: _this.global.curTap
								})
							} else {
								_this.funs.getList()
							}
						} else {
							$("#mod_submain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 12:
			if (!_this.global.fmlist.isLoad && !_this.global.fmlist.isOver) {
				_this.global.fmlist.isLoad = true;
				if (_this.global.fmlist.curPage == 1) {
					_this.funs.showLoading()
				} else {
					$("#mod_submain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					dataType: "json",
					data: {
						pageindex: _this.global.fmlist.curPage,
						pagesize: _this.global.fmlist.pageSize
					},
					url: KGMO.url.fmUrl,
					type: "get",
					isLoad: function() {
						_this.global.fmlist.isOver = false
					},
					isOver: function() {
						_this.global.fmlist.isOver = true;
						$("#mod_submain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.fmlist.isLoad = false;
						if (_this.util.isOnline()) {
							if (_this.global.fmlist.curPage == 1) {
								_this.funs.changeTab({
									tab: _this.global.curTap
								})
							} else {
								_this.funs.getList()
							}
						} else {
							$("#mod_submain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 13:
			if (_this.global.ringlist.detail.data.length > 1) {
				_this.funs.setList({
					data: _this.global.ringlist.detail.data
				})
			} else {
				if (!_this.global.ringlist.detail.isLoad && !_this.global.ringlist.detail.isOver) {
					_this.global.ringlist.detail.isLoad = true;
					if (_this.global.ringlist.detail.curPage == 1) {
						_this.funs.showLoading();
						_this.global.ringlist.detail.data = []
					} else {
						$("#mod_detailmain").find(".loadstatus").html("加载中……").show()
					}
					meta = {
						dataType: "json",
						data: {
							pagesize: _this.global.ringlist.detail.pageSize
						},
						url: KGMO.url.ringUrl,
						type: "get",
						isLoad: function() {
							_this.global.ringlist.detail.isOver = false
						},
						isOver: function() {
							_this.global.ringlist.detail.isOver = true;
							$("#mod_detailmain").find(".loadstatus").hide()
						},
						err: function() {
							_this.global.ringlist.detail.isLoad = false;
							if (_this.util.isOnline()) {
								_this.funs.getList()
							} else {
								$("#mod_detailmain").find(".loadstatus").html("加载超时").show()
							}
						}
					};
					loadData(meta)
				}
			}
			break;
		case 20:
			var singerData = _this.global.singerlist;
			if (!singerData.isLoad && !singerData.isOver) {
				singerData.isLoad = true;
				if (singerData.curPage == 1) {
					_this.funs.showLoading();
					_this.global.singerlist.data = []
				} else {
					$("#mod_submain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					data: {
						cmd: 101,
						outputtype: "jsonp",
						classid: _this.global.singerlist.tid,
						page: singerData.curPage,
						pagesize: singerData.pagesize
					},
					url: KGMO.url.singerClassUrl,
					type: "get",
					isLoad: function() {
						_this.global.singerlist.isOver = false
					},
					isOver: function() {
						_this.global.singerlist.isOver = true;
						$("#mod_submain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.singerlist.isLoad = false;
						if (_this.util.isOnline()) {
							_this.funs.getList()
						} else {
							$("#mod_submain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 4:
			var searchData = _this.global.search.detail;
			if (searchData.keyword !== "" && !searchData.isLoad && !searchData.isOver) {
				searchData.isLoad = true;
				if (searchData.curPage == 1) {
					_this.funs.showLoading();
					searchData.data = [];
					$("#search_result").find("ul").html("")
				} else {
					$("#search_result").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					data: {
						format: "jsonp",
						keyword: decodeURIComponent(searchData.keyword),
						page: searchData.curPage,
						pagesize: searchData.pageSize,
						showtype: 1
					},
					url: KGMO.url.searchUrl,
					type: "get",
					isLoad: function() {
						searchData.isOver = false
					},
					isOver: function() {
						searchData.isOver = true
					},
					cb: function() {
						if (searchData.curPage == 1 && searchData.data.length < 1) {
							$("#search_result").html('<div class="noresult">抱歉，没有找到相关的歌曲</div>')
						}
					},
					err: function() {
						searchData.isLoad = false;
						if (_this.util.isOnline()) {
							_this.funs.getList()
						} else {
							$("#search_result").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 100:
			if (!_this.global.banglist.detail.isLoad && !_this.global.banglist.detail.isOver) {
				_this.global.banglist.detail.isLoad = true;
				if (_this.global.banglist.detail.curPage == 1) {
					_this.funs.showLoading();
					_this.global.banglist.detail.data = []
				} else {
					$("#mod_detailmain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					dataType: "jsonp",
					data: {
						cmd: 101,
						outputtype: "jsonp",
						cid: _this.global.banglist.detail.cid,
						type: _this.global.banglist.detail.cid,
						page: _this.global.banglist.detail.curPage,
						pagesize: _this.global.banglist.detail.pageSize
					},
					url: KGMO.url.listurl,
					type: "get",
					isLoad: function() {
						_this.global.banglist.detail.isOver = false
					},
					isOver: function() {
						_this.global.banglist.detail.isOver = true;
						$("#mod_detailmain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.banglist.detail.isLoad = false;
						if (_this.util.isOnline()) {
							_this.funs.getList()
						} else {
							$("#mod_detailmain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 101:
			if (!_this.global.playlist.detail.isLoad && !_this.global.playlist.detail.isOver) {
				_this.global.playlist.detail.isLoad = true;
				if (_this.global.playlist.detail.curPage == 1) {
					_this.funs.showLoading();
					_this.funs.getSpecialInfo();
					_this.global.playlist.detail.data = []
				} else {
					$("#mod_detailmain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					dataType: "jsonp",
					data: {
						cmd: 107,
						outputtype: "jsonp",
						cid: _this.global.playlist.detail.sid,
						page: _this.global.playlist.detail.curPage,
						pagesize: _this.global.playlist.detail.pageSize,
						ctype: _this.global.playlist.detail.ctype
					},
					url: KGMO.url.specialUrl,
					type: "get",
					isLoad: function() {
						_this.global.playlist.detail.isOver = false
					},
					isOver: function() {
						_this.global.playlist.detail.isOver = true;
						$("#mod_detailmain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.playlist.detail.isLoad = false;
						if (_this.util.isOnline()) {
							_this.funs.getList()
						} else {
							$("#mod_detailmain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		case 200:
			if (!_this.global.singerlist.detail.isLoad && !_this.global.singerlist.detail.isOver) {
				_this.global.singerlist.detail.isLoad = true;
				if (_this.global.singerlist.detail.curPage == 1) {
					_this.funs.showLoading();
					_this.global.singerlist.detail.data = [];
					_this.funs.setSingerDetail();
					$("#singerdetail").find(".detaillist").html("")
				} else {
					$("#mod_detailmain").find(".loadstatus").html("加载中……").show()
				}
				meta = {
					dataType: "jsonp",
					data: {
						format: "jsonp",
						singerid: _this.global.singerlist.detail.singerid,
						page: _this.global.singerlist.detail.curPage,
						pagesize: _this.global.singerlist.detail.pageSize
					},
					url: KGMO.url.singerSongsList,
					type: "get",
					isLoad: function() {
						_this.global.singerlist.detail.isOver = false
					},
					isOver: function() {
						_this.global.singerlist.detail.isOver = true;
						$("#mod_detailmain").find(".loadstatus").hide()
					},
					err: function() {
						_this.global.singerlist.detail.isLoad = false;
						if (_this.util.isOnline()) {
							_this.funs.getList()
						} else {
							$("#mod_detailmain").find(".loadstatus").html("加载超时").show()
						}
					}
				};
				loadData(meta)
			}
			break;
		default:
			break
		}
	},
	setBangDetail: function() {
		var _this = KGMO,
			_bangdetail = $("#bangdetail"),
			data = _this.global.banglist.data,
			curData = {},
			isExist = false;
		for (var i = 0, l = data.length; i < l; i++) {
			if (_this.global.banglist.detail.cid == data[i].cid) {
				curData = data[i];
				isExist = true;
				break
			}
		}
		if (isExist) {
			_bangdetail.find(".hd img").attr("src", _this.util.getBangImg({
				img: curData.imgurl,
				size: 85
			}));
			_bangdetail.find(".hd h5").html(curData.cname);
			_bangdetail.find(".hd p").html(curData.description);
			_bangdetail.find(".hd").show()
		} else if (_this.global.banglist.data.length === 0 && !_this.global.banglist.outOpen) {
			$.ajax({
				type: 'get',
				url: _this.url.listurl,
				dataType: 'jsonp',
				data: {
					cmd: 100,
					outputtype: "jsonp",
					pagesize: 1000,
					cid: 21,
					mix: 1
				},
				success: function(res) {
					if (res && res["data"].length > 0) {
						_this.global.banglist.data = res["data"];
						_this.global.banglist.outOpen = true;
						_this.funs.setBangDetail()
					}
				},
				error: function(res) {}
			})
		}
	},
	getSpecialInfo: function() {
		var _this = KGMO,
			_playdetail = $("#playdetail");
		$.ajax({
			type: "get",
			url: _this.url.specialInfo,
			data: {
				cmd: 108,
				cid: _this.global.playlist.detail.sid,
				ctype: _this.global.playlist.detail.ctype,
				outputtype: "jsonp"
			},
			dataType: "jsonp",
			timeout: KGMO.global.timeout,
			success: function(res) {
				if (res && res["status"] == 1) {
					if (res.imgurl !== "") {
						_playdetail.find(".hd img").attr("src", _this.util.getBangImg({
							img: res.imgurl
						}))
					}
					_playdetail.find(".hd p").html(res["description"]);
					$("#tabtitle").html(res['cname']);
					_playdetail.find(".hd").show()
				}
			}
		})
	},
	setList: function(o) {
		var html = [],
			data, tmpIndex = [],
			tmpLen = 0,
			_this = KGMO,
			songData = '',
			_mod_submain = $("#mod_submain"),
			idx = 0;
		switch (_this.global.curTab) {
		case 0:
			tmpLen = _this.player.songs.length;
			_this.global.newslist.data = _this.global.newslist.data.concat(o.data);
			var _mod_newslist = $("#mod_newslist");
			data = o.data;
			if (data.length < _this.global.newslist.pageSize) {
				_this.global.newslist.isOver = true
			}
			idx = _this.global.newslist.pageSize * (_this.global.newslist.curPage - 1);
			for (i = 0, l = data.length; i < l; i++) {
				html.push('<li><a href="javascript:;" onclick="KGMO.api.playRankSong({type:1,idx:' + (idx + i) + '})"><em>' + (idx + i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})""><i></i></div></li>')
			}
			_mod_newslist.find("ul").append(html.join(""));
			_this.global.newslist.curPage++;
			_this.global.newslist.isLoad = false;
			$("#mod_newslist").find(".loadstatus").hide();
			break;
		case 10:
			_this.global.banglist.data = _this.global.banglist.data.concat(o.data);
			data = o.data;
			if (data.length < _this.global.banglist.pageSize) {
				_this.global.banglist.isOver = true
			}
			for (i = 0, l = data.length; i < l; i++) {
				html.push('<li onclick="KGMO.api.showBangInfo({cid:' + data[i]['cid'] + ',name:\'' + escape(data[i]["cname"]) + '\'})"><a href="javascript:;" class="pic"><img src="' + KGMO.url.defaultSingerHead + '" data-url="' + _this.util.getBangImg({
					"img": data[i]['imgurl'],
					size: 85
				}) + '" alt=""/></a><span>' + data[i]['cname'] + '</span><div class="btn_more"><i></i></div></li>')
			}
			_mod_submain.find(".subbanglist").append(html.join("")).show();
			if (_this.global.banglist.curPage == 1) {
				_mod_submain.find(".subbanglist img").each(function() {
					$(this).attr("src", $(this).attr("data-url"))
				})
			} else {
				_mod_submain.find(".subbanglist img").imglazyload({})
			}
			_this.global.banglist.curPage++;
			_this.global.banglist.isLoad = false;
			$("#mod_submain").find(".loadstatus").hide();
			break;
		case 11:
			_this.global.playlist.data = _this.global.playlist.data.concat(o.data);
			data = o.data;
			for (i = 0, l = data.length; i < l; i++) {
				html.push('<li onclick="KGMO.api.showPlayList({sid:' + data[i]['cid'] + '})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + _this.util.getBangImg({
					img: data[i]['imgurl'],
					size: 400
				}) + '" alt=""/></a><span>' + data[i]['cname'] + '</span><div class="btn_more"><i></i></div></li>')
			}
			_mod_submain.find(".subplaylist").append(html.join("")).show();
			if (_this.global.playlist.curPage == 1) {
				_mod_submain.find(".subplaylist img").each(function() {
					$(this).attr("src", $(this).attr("data-url"))
				})
			} else {
				_mod_submain.find(".subplaylist img").imglazyload({})
			}
			_this.global.playlist.curPage++;
			_this.global.playlist.isLoad = false;
			$("#mod_submain").find(".loadstatus").hide();
			break;
		case 12:
			_this.global.fmlist.data = _this.global.fmlist.data.concat(o.data);
			data = o.data;
			for (i = 0, l = data.length; i < l; i++) {
				var tmpsong = data[i]["fmSongData"][0]["songs"][0];
				songData = tmpsong["hash"] + "|" + Math.ceil(tmpsong["time"] / 1000) + "|" + tmpsong["size"] + "|" + tmpsong["bitrate"];
				if (i % 2 === 0) {
					html.push('<div class="list">')
				}
				html.push('<div class="item" fmid="' + data[i]['fmid'] + '" onclick="KGMO.api.playFmSongs({fmid:' + data[i]['fmid'] + '})"><a href="javascript:;" class="pic"><img src="' + _this.url.defaultSingerHead + '" data-url="' + _this.util.getFmImg({
					img: data[i]["imgurl"]
				}) + '" alt=""/><span class="fmname">' + data[i]["fmname"] + '</span></a></div>');
				if (i % 2 === 1) {
					html.push('</div>')
				}
			}
			_mod_submain.find(".subfmlist").append(html.join("")).show();
			if (_this.global.fmlist.curPage == 1) {
				_mod_submain.find(".subfmlist img").each(function() {
					$(this).attr("src", $(this).attr("data-url"))
				})
			} else {
				_mod_submain.find(".subfmlist img").imglazyload({})
			}
			_this.global.fmlist.curPage++;
			_this.global.fmlist.isLoad = false;
			$("#mod_submain").find(".loadstatus").hide();
			break;
		case 13:
			_this.global.ringlist.detail.data = o.data;
			data = o.data;
			for (i = 0; i < data.length; i++) {
				html.push('<li><a href="javascript:;" onclick="KGMO.api.playRankSong({type:130,idx:' + i + '})" class="tit"><em>' + (i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><a href="javascript:;" onclick="KGMO.api.ringOrder({musicId:\'' + data[i]["id"] + '\'})" class="btn_buy">订购</a></li>')
			}
			_mod_submain.find(".subringlist ul").html(html.join(""));
			_mod_submain.find(".subringlist").show();
			_this.global.ringlist.curPage++;
			_this.global.ringlist.isLoad = false;
			$("#mod_submain").find(".loadstatus").hide();
			break;
		case 20:
			_this.global.singerlist.data = _this.global.singerlist.data.concat(o.data);
			data = o.data;
			for (i = 0, l = data.length; i < l; i++) {
				html.push('<li onclick="KGMO.api.showSingerInfo({singerid:' + data[i]["singerid"] + '})"><a href="javascript:;" class="pic"><img src="' + KGMO.url.defaultSingerHead + '" data-url="' + _this.util.getSingerImg({
					img: data[i]['imgurl'],
					size: 120
				}) + '" alt=""/></a><span>' + data[i]['singer'] + '</span><div class="btn_more"><i></i></div></li>')
			}
			_mod_submain.find(".subsingerlist").append(html.join("")).show();
			if (_this.global.singerlist.curPage == 1) {
				_mod_submain.find(".subsingerlist img").each(function() {
					$(this).attr("src", $(this).attr("data-url"))
				})
			} else {
				_mod_submain.find(".subsingerlist img").imglazyload({})
			}
			_this.global.singerlist.curPage++;
			_this.global.singerlist.isLoad = false;
			$("#mod_submain").find(".loadstatus").hide();
			break;
		case 4:
			data = _this.funs.formatSingerSongs({
				songs: o.data
			});
			_this.global.search.detail.data = _this.global.search.detail.data.concat(data);
			if (data.length < _this.global.search.detail.pageSize) {
				_this.global.search.detail.isOver = true
			}
			for (i = 0, l = data.length; i < l; i++) {
				songData = data[i]["hash"] + "|" + data[i]["timelength"] + "|" + data[i]["size"] + "|" + data[i]["bitrate"];
				if (data[i]['hash'] !== "") {
					html.push('<li><a href="javascript:;" idx="' + (_this.global.search.detail.pageSize * (_this.global.search.detail.curPage - 1) + i) + '" data="' + songData + '"><em>' + (_this.global.search.detail.pageSize * (_this.global.search.detail.curPage - 1) + i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})"><i></i></div></li>')
				}
			}
			var _search_result = $("#search_result");
			_search_result.find("ul").append(html.join(""));
			_search_result.show();
			_this.global.search.detail.curPage++;
			_this.global.search.detail.isLoad = false;
			break;
		case 100:
			if (_this.global.banglist.detail.curPage == 1) {
				_this.funs.setBangDetail();
				_this.global.banglist.detail.data = []
			}
			_this.global.banglist.detail.data = _this.global.banglist.detail.data.concat(o.data);
			var _bangdetail = $("#bangdetail");
			data = o.data;
			if (data.length < _this.global.banglist.detail.pageSize) {
				_this.global.banglist.detail.isOver = true
			}
			idx = _this.global.banglist.detail.pageSize * (_this.global.banglist.detail.curPage - 1);
			for (i = 0, l = data.length; i < l; i++) {
				if (data[i]['hash'] !== "") {
					html.push('<li><a href="javascript:;" cid="' + _this.global.banglist.detail.cid + '" onclick="KGMO.api.playRankSong({type:100,idx:' + (idx + i) + '})"><em>' + (idx + i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})"><i></i></div></li>')
				}
			}
			_bangdetail.find(".detaillist").append(html.join(""));
			_this.global.banglist.detail.curPage++;
			_this.global.banglist.detail.isLoad = false;
			$("#mod_detailmain").find(".loadstatus").hide();
			break;
		case 101:
			_this.global.playlist.detail.data = _this.global.playlist.detail.data.concat(o.data);
			var _playdetail = $("#playdetail");
			data = o.data;
			if (data.length < _this.global.playlist.detail.pageSize) {
				_this.global.playlist.detail.isOver = true
			}
			idx = _this.global.playlist.detail.pageSize * (_this.global.playlist.detail.curPage - 1);
			for (i = 0, l = data.length; i < l; i++) {
				if (data[i]['hash'] !== "") {
					html.push('<li><a href="javascript:;" idx="' + idx + '" onclick="KGMO.api.playRankSong({idx : ' + (idx + i) + ',type : 101})"><em>' + (idx + i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})"><i></i></div></li>')
				}
			}
			_playdetail.find(".detaillist").append(html.join(""));
			_this.global.playlist.detail.curPage++;
			_this.global.playlist.detail.isLoad = false;
			$("#mod_detailmain").find(".loadstatus").hide();
			break;
		case 200:
			data = _this.funs.formatSingerSongs({
				songs: o.data
			});
			_this.global.singerlist.detail.data = _this.global.singerlist.detail.data.concat(data);
			if (data.length < _this.global.singerlist.detail.pageSize) {
				_this.global.singerlist.detail.isOver = true
			}
			idx = _this.global.singerlist.detail.pageSize * (_this.global.singerlist.detail.curPage - 1);
			for (i = 0, l = data.length; i < l; i++) {
				if (data[i]['hash'] !== "") {
					html.push('<li><a href="javascript:;" onclick="KGMO.api.playRankSong({type:200,idx:' + (idx + i) + '})"><em>' + (idx + i + 1) + '.</em><span>' + data[i]["filename"] + '</span></a><div class="btn_down" onclick="KGMO.api.downSong({hash:\'' + data[i]['hash'] + '\',el:this})"><i></i></div></li>')
				}
			}
			_singerdetail = $("#singerdetail");
			_singerdetail.find(".detaillist").append(html.join(""));
			_singerdetail.show();
			_this.global.singerlist.detail.curPage++;
			_this.global.singerlist.detail.isLoad = false;
			$("#mod_detailmain").find(".loadstatus").hide();
			break;
		default:
			break
		}
		_this.funs.hideLoading()
	},
	createSlider: function() {
		var sliderCB = function() {
				var html = [],
					pos_html = [],
					data = KGMO.global.bannerData,
					len = data.length,
					_mod_slider = $("#mod_slider");
				pos_html.push('<div class="on"><span></span></div>');
				if (len > 0) {
					for (var i = 0; i < len; i++) {
						var action = data[i]["action"],
							extra = data[i]["extra"];
						pos_html.push('<div><span></span></div>');
						switch (action) {
						case 1:
							html.push('<div><a href="javascript:;" onclick="KGMO.api.showPlayList({sid:' + data[i]['extra']['cid'] + ',ctype:' + data[i]['extra']['ctype'] + '})"><img src="' + data[i]["bannerurl"] + '" onerror="this.onerror=null;this.src=\'http://m.kugou.com/static/images/index2013/default_ban.jpg\';" alt=""/></a></div>');
							break;
						case 2:
							html.push('<div><a href="' + extra["href"] + '" target="_blank"><img src="' + data[i]["bannerurl"] + '" onerror="this.onerror=null;this.src=\'http://m.kugou.com/static/images/index2013/default_ban.jpg\';" alt=""/></a></div>');
							break;
						case 3:
							html.push('<div><a href="' + extra["href"] + '" target="_blank"><img src="' + data[i]["bannerurl"] + '" onerror="this.onerror=null;this.src=\'http://m.kugou.com/static/images/index2013/default_ban.jpg\';" alt=""/></a></div>');
							break;
						default:
							break
						}
						if (i == 3) {
							break
						}
					}
					_mod_slider.find(".swipe_wrap").append(html.join(""));
					_mod_slider.find(".swipe_pos").html(pos_html.join(""));
					_mod_slider.show();
					KGMO.funs.initSlider()
				}
			};
		if (KGMO.global.isShowSlider) {
			$.ajax({
				type: 'get',
				url: KGMO.url.banner,
				data: {
					outputtype: "jsonp",
					cmd: 512,
					plat: 0,
					num: 6
				},
				dataType: 'jsonp',
				timeout: KGMO.global.timeout,
				success: function(res) {
					if (res && res["status"] == 1) {
						KGMO.global.bannerData = res["data"];
						sliderCB()
					} else {
						$("#mod_slider").hide()
					}
				},
				error: function(xhr, type) {
					$("#mod_slider").hide()
				}
			})
		}
	},
	initSlider: function() {
		try {
			if (KGMO.global.slider) {
				KGMO.global.slider.setup()
			} else {
				var _mod_slider = $("#mod_slider"),
					bullets = _mod_slider.find(".swipe_pos div");
				KGMO.global.slider = new Swipe(_mod_slider.get(0), {
					auto: 6000,
					continuous: true,
					callback: function(pos, duration) {
						bullets.removeClass("on");
						$(bullets.get(pos)).addClass("on")
					}
				})
			}
		} catch (e) {}
	},
	hideLoading: function() {
		$("#loading").hide()
	},
	showLoading: function() {
		$("#loading").show()
	}
};
KGMO.player = {
	fatherId: null,
	playerId: null,
	songs: [],
	index: 0,
	playMode: "order",
	playType: 0,
	playIndex: [],
	playSt: null,
	randomSortIndex: 0,
	isPlayRadio: false,
	isPlayRing: false,
	init: function(o) {
		var _this = KGMO.player;
		_this.fatherId = o.fatherId;
		_this.playerId = o.playerId;
		_this.setPlayTime()
	},
	setAllTime: function() {
		if (KGMO.player.songs[KGMO.player.index].timelength) {
			$("#time").html(KGMO.player.getAllTime())
		}
	},
	getAllTime: function() {
		var times = KGMO.player.songs[KGMO.player.index].timelength;
		var mins = Math.floor(times / 60);
		var secs = times % 60;
		return KGMO.util.addZero(mins) + ":" + KGMO.util.addZero(secs)
	},
	getTimeLength: function() {
		if (KGMO.player.songs[KGMO.player.index].timelength) {
			return KGMO.player.songs[KGMO.player.index].timelength
		} else {
			return 0
		}
	},
	setSinHead: function(o) {
		var _this = KGMO;
		$.ajax({
			type: "get",
			url: _this.url.getSingerHead,
			data: {
				"singerName": $.trim(o.name)
			},
			dataType: 'json',
			timeout: _this.global.timeout,
			success: function(res) {
				if (o.hash == _this.player.songs[_this.player.index].hash) {
					if (res && res["status"] == 1) {
						if (res["url"] && res["url"] !== "") {
							$("#singerhead").find("img").attr("src", _this.util.getSingerImg({
								img: res["url"],
								size: 68
							}));
							$("#mod_mainplayer").find(".cover img").attr("src", _this.util.getSingerImg({
								img: res["url"],
								size: 400
							}))
						} else {
							$("#singerhead").find("img").attr("src", _this.url.defaultSingerHead);
							$("#mod_mainplayer").find(".cover img").attr("src", _this.url.defaultSingerHead)
						}
					}
				}
			},
			error: function(xhr, type) {
				$("#singerHead").attr("src", _this.url.defaultSingerHead)
			}
		})
	},
	setTitle: function() {
		var _this = KGMO,
			name = _this.player.songs[_this.player.index].filename;
		$("#songname").html(name);
		$("#songtitle").html(name);
		if (!KGMO.player.isMin) {
			document.title = name + "酷狗音乐"
		}
	},
	ended_handle: function() {
		var _this = KGMO;
		if (_this.player.isPlayRadio) {
			_this.player.getFmSongs()
		}
		if (_this.player.playMode == "single") {
			_this.player.setCurrentTime({
				time: 0
			});
			_this.player.play()
		} else if (_this.player.playMode == "order" || _this.player.playMode == "list") {
			_this.player.pause();
			if (_this.player.playMode == "order") {
				if ((_this.player.index + 1) < _this.player.songs.length) {
					_this.player.playNextSong()
				}
			} else {
				_this.player.playNextSong()
			}
		} else if (_this.player.playMode == "random") {
			_this.player.playNextSong()
		}
	},
	create: function(o) {
		var _this = KGMO,
			src = "about:blank",
			name = "",
			metadata = $.param({
				"hash": o.hash,
				"cmd": "playInfo"
			});
		if (!KGMO.util.isCanPlayAudio()) {
			$("#songname").html("此款手机不支持HTML5播放");
			return
		}
		_this.player.preLoad();
		if (_this.util.isIOS()) {
			_this.player.play();
			_this.player.pause()
		}
		var playSong = function() {
				if (_this.util.isIOS()) {
					$("#" + _this.player.playerId).attr("src", src)
				} else {
					$("#" + _this.player.fatherId).html('<audio id="' + _this.player.playerId + '" onended="KGMO.player.ended_handle()" src="' + src + '" autoplay="autoplay" controls></audio>')
				}
				_this.player.play();
				name = o.filename.split("-")[0];
				_this.player.setSinHead({
					"name": name,
					"hash": o.hash
				});
				_this.player.setPlayProgress();
				if (o.hash) {
					_this.player.lrc.get({
						hash: o.hash
					})
				} else {
					$("#lrc").html('<div class="nolrc">彩铃不支持歌词</div>')
				}
			};
		if (o.hash) {
			$.ajax({
				type: 'GET',
				url: _this.url.getSongInfo,
				data: metadata,
				async: false,
				dataType: 'json',
				success: function(res) {
					if (res && res["status"] == 1) {
						src = res.url
					}
					if (res["hash"] == _this.player.songs[_this.player.index].hash) {
						$("#" + _this.player.fatherId).attr("hash", o.hash);
						playSong()
					}
				},
				error: function(res) {}
			})
		} else {
			if (_this.player.songs[_this.player.index].songurl) {
				src = _this.player.songs[_this.player.index].songurl
			}
			playSong()
		}
	},
	preLoad: function() {
		$("#singerhead i,#mod_mainplayer .cover i").show();
		$("#singerhead").find("img").attr("src", KGMO.url.defaultSingerHead);
		$("#mod_mainplayer").find(".cover img").attr("src", KGMO.url.defaultSingerHead)
	},
	getPlayTime: function() {
		var _this = KGMO,
			times = Math.ceil(_this.player.getCurrentTime()),
			mins = 0,
			secs = 0;
		if (times > 1 && _this.player.songs[_this.player.index].timelength) {
			if (times > _this.player.songs[_this.player.index].timelength) {
				times = _this.player.songs[_this.player.index].timelength
			}
			mins = Math.floor(times / 60);
			secs = times % 60;
			$("#singerhead i,#mod_mainplayer .cover i").hide();
			return KGMO.util.addZero(mins) + ":" + KGMO.util.addZero(secs)
		} else if (times > 1) {
			_this.player.songs[_this.player.index].timelength = Math.ceil($("#" + _this.player.playerId).get(0).duration);
			_this.player.setAllTime();
			return "00:01"
		} else {
			return "00:00"
		}
	},
	setPlayTime: function() {
		KGMO.player.playSt = setInterval(function() {
			$("#timeshow").html(KGMO.player.getPlayTime())
		}, 1000)
	},
	playNextSong: function() {
		var _this = KGMO;
		if (_this.player.isPlayRadio) {
			_this.player.getFmSongs()
		}
		if (_this.player.playMode == "random") {
			_this.player.randomSortIndex++;
			if (_this.player.randomSortIndex >= _this.player.playIndex.length) {
				_this.player.randomSortIndex = 0
			}
			_this.player.index = _this.player.playIndex[_this.player.randomSortIndex]
		} else {
			_this.player.index++;
			if (_this.player.index >= _this.player.songs.length) {
				_this.player.index = 0
			}
		}
		_this.player.setTitle();
		_this.player.setAllTime();
		_this.player.create({
			hash: _this.player.songs[_this.player.index].hash,
			filename: _this.player.songs[_this.player.index].filename
		})
	},
	playPrevSong: function() {
		var _this = KGMO;
		if (_this.player.isPlayRadio) {
			return
		}
		if (_this.player.playMode == "random") {
			_this.player.randomSortIndex--;
			if (_this.player.randomSortIndex < 0) {
				_this.player.randomSortIndex = _this.player.playIndex.length - 1
			}
			_this.player.index = _this.player.playIndex[_this.player.randomSortIndex]
		} else {
			_this.player.index--;
			if (_this.player.index < 0) {
				_this.player.index = _this.player.songs.length - 1
			}
		}
		_this.player.setTitle();
		_this.player.setAllTime();
		_this.player.create({
			hash: _this.player.songs[_this.player.index].hash,
			filename: _this.player.songs[_this.player.index].filename
		})
	},
	getSongsNum: function() {
		return KGMO.player.songs.length
	},
	changePlayMode: function() {
		var _this = KGMO;
		if (_this.player.isPlayRadio) {
			alert("播放模式对电台无效！")
		} else {
			if (_this.player.playMode == "order") {
				_this.player.setPlaymode({
					mode: "list"
				});
				$("#playmode").attr("class", "btn btn_list");
				console.debug("列表循环")
			} else if (_this.player.playMode == "list") {
				_this.player.setPlaymode({
					mode: "random"
				});
				$("#playmode").attr("class", "btn btn_random");
				console.debug("随机播放")
			} else if (_this.player.playMode == "random") {
				_this.player.setPlaymode({
					mode: "single"
				});
				$("#playmode").attr("class", "btn btn_single");
				console.debug("单曲循环")
			} else if (_this.player.playMode == "single") {
				_this.player.setPlaymode({
					mode: "order"
				});
				$("#playmode").attr("class", "btn btn_order");
				console.debug("顺序播放")
			}
		}
	},
	setPlaymode: function(o) {
		var _this = KGMO;
		_this.player.playMode = o.mode;
		if (o.mode == "random") {
			_this.player.randomSortIndex = 0;
			for (i = 0; i < _this.player.getSongsNum(); i++) {
				_this.player.playIndex[i] = i
			}
			_this.player.playIndex.sort(KGMO.funs.randomSort);
			for (var i = 0; i < _this.player.playIndex.length; i++) {
				if (o.idx == _this.player.playIndex[i]) {
					_this.player.randomSortIndex = i;
					break
				}
			}
		}
	},
	getFmSongs: function() {
		var _this = KGMO,
			data = [];
		if (!_this.global.fmlist.detail.isLoad) {
			_this.global.fmlist.detail.isLoad = true;
			$.ajax({
				type: "get",
				url: _this.url.fmSongsUrl,
				async: false,
				data: {
					fmid: _this.global.fmlist.detail.fmid,
					offset: _this.global.fmlist.detail.offset,
					size: _this.global.fmlist.detail.pageSize
				},
				dataType: "json",
				timeout: _this.global.timeout,
				success: function(res) {
					if (res && res["status"] == 1) {
						_this.global.fmlist.detail.offset = res["data"][0]["offset"];
						data = _this.funs.formatFmSongs({
							songs: res["data"][0]["songs"],
							fmid: _this.global.fmlist.detail.fmid
						});
						_this.player.songs = _this.player.songs.concat(data);
						_this.global.fmlist.detail.isLoad = false
					}
				},
				error: function() {
					_this.global.fmlist.detail.isLoad = false
				}
			})
		}
	},
	setSongsPlay: function(o) {
		var _this = KGMO;
		_this.player.playType = o.type;
		_this.player.index = o.idx;
		switch (_this.player.playType) {
		case 1:
			_this.player.songs = _this.global.newslist.data;
			break;
		case 100:
			_this.player.songs = _this.global.banglist.detail.data;
			break;
		case 101:
			_this.player.songs = _this.global.playlist.detail.data;
			break;
		case 200:
			_this.player.songs = _this.global.singerlist.detail.data;
			break;
		case 300:
			_this.player.songs = _this.global.collect.detail.data;
			break;
		case 4:
			_this.player.songs = _this.global.search.detail.data;
			break;
		case 13:
			_this.player.songs = _this.global.ringlist.data;
			break;
		case 130:
			_this.player.songs = _this.global.ringlist.detail.data;
			break;
		default:
			break
		}
		_this.player.setPlaymode({
			mode: _this.player.playMode
		});
		_this.player.setTitle();
		_this.player.setAllTime();
		_this.player.create({
			hash: _this.player.songs[o.idx].hash,
			filename: _this.player.songs[o.idx].filename
		})
	},
	addSongsPlay: function(o) {
		var _this = KGMO;
		_this.player.playType = o.playType;
		_this.player.songs = o.songs;
		_this.player.index = 0;
		_this.player.randomSortIndex = 0;
		_this.player.setTitle();
		_this.player.setAllTime();
		_this.player.create({
			hash: _this.player.songs[_this.player.index].hash,
			filename: _this.player.songs[_this.player.index].filename
		})
	},
	setSongsNoPlay: function(songs) {},
	play: function() {
		var _this = KGMO;
		try {
			if ($("#" + _this.player.playerId).attr("src") == "about:blank") {
				_this.player.pause()
			} else {
				$("#" + _this.player.playerId).get(0).play();
				$("#btn_play").removeClass("btn_play").addClass("btn_pause");
				$("#btn_mainplay").removeClass("btn_play").addClass("btn_pause");
				clearInterval(_this.player.playSt);
				_this.player.setPlayTime()
			}
		} catch (e) {}
	},
	pause: function() {
		var _this = KGMO;
		try {
			clearInterval(_this.player.playSt);
			$("#" + _this.player.playerId).get(0).pause();
			$("#btn_play").removeClass("btn_pause").addClass("btn_play");
			$("#btn_mainplay").removeClass("btn_pause").addClass("btn_play");
			$("#singerhead i,#mod_mainplayer .cover i").hide()
		} catch (e) {}
	},
	prevPlayData: function() {},
	setPlayProgress: function() {
		var _this = KGMO;
		clearInterval(_this.global.progressSt);
		_this.global.progressSt = setInterval(function() {
			var per = _this.player.getCurrentTime() / _this.player.getTimeLength() * 100;
			if (per > 100) {
				per = 100
			}
			$("#progress").css("width", per + "%")
		}, 1000)
	},
	getBuffered: function() {
		try {
			return $("#" + KGMO.player.playerId).get(0).buffered
		} catch (e) {}
		return 0
	},
	setCurrentTime: function(o) {
		$("#" + KGMO.player.playerId).get(0).currentTime = o.time
	},
	getCurrentTime: function() {
		try {
			return $("#" + KGMO.player.playerId).get(0).currentTime
		} catch (e) {}
		return 0
	},
	setVolume: function(o) {
		try {
			document.getElementById(KGMO.playerId).volume = o.num
		} catch (e) {}
	},
	lrc: {
		getLrcStatus: function() {
			var _this = KGMO;
			if (_this.global.uiLRC && _this.global.uiLRC.IsLyricValid()) {
				setInterval(function() {
					try {
						_this.global.uiLRC.DoSync(parseInt(_this.player.getCurrentTime(), 10))
					} catch (e) {}
				}, 1000)
			}
		},
		get: function(o) {
			var _this = KGMO,
				song = _this.player.songs[_this.player.index].filename,
				timelength = _this.player.songs[_this.player.index].timelength,
				metadata = $.param({
					"keyword": song,
					"timelength": timelength,
					"hash": o.hash,
					"cmd": 100
				});
			$("#lrc").html('<div class="nolrc">歌词搜索中...</div>');
			_this.global.uiLRC = null;
			$.get(_this.url.lrc, metadata, function(result) {
				if (result !== "") {
					_this.global.uiLRC = new LRC({
						lyric: result,
						lyricWrapper: $("#lrc").get(0),
						curRowClassName: 'current',
						separator: '\r\n'
					});
					_this.player.lrc.getLrcStatus()
				} else {
					$("#lrc").html('<div class="nolrc">没有找到歌词</div>')
				}
			})
		}
	}
};
KGMO.order = {
	isOrder: false,
	url: {
		songInfoUrl: "http://cmccservice.kugou.com/music/info",
		sendCodeUrl: "http://cmccservice.kugou.com/crbt/getvalidatecode",
		checkMobileUrl: "http://cmccservice.kugou.com/crbt/chkopen",
		buyOrderUrl: "http://cmccservice.kugou.com/crbt/order"
	},
	countDown: function(o) {
		var _countdown = $("#countdown");
		if (o.time > 0) {
			o.time--;
			$(o.dom).attr("disabled", "disabled");
			setTimeout(function() {
				$(o.dom).html("重新获取(" + o.time + "s)");
				KGMO.order.countDown(o)
			}, 1000)
		} else {
			$(o.dom).html("重新获取");
			$(o.dom).removeAttr("disabled")
		}
	},
	checkMobileCB: function(o) {
		var _this = KGMO,
			_mod_ringorder = $("#mod_ringorder");
		if (o) {
			if (o.resCode == "000000") {
				_this.order.optRing({
					cmd: 2
				})
			} else {
				$("#btn_sendcmccode").removeAttr("disabled").html("获取短信验证码");
				alert("该号码未开通彩铃功能！");
				_this.util.scrollToTop()
			}
		}
	},
	getRingCodeCB: function(o) {
		var _this = KGMO,
			_mod_ringorder = $("#mod_ringorder");
		if (o && _this.global.ringlist.sendMusicId == _this.global.ringlist.musicId) {
			if (o.resCode == "000000") {
				_mod_ringorder.find(".open_phone").html(_this.global.ringlist.mobile);
				_mod_ringorder.find(".step1,.step2,.step3").hide();
				_mod_ringorder.find(".step2").show();
				_this.order.countDown({
					dom: $("#countdown"),
					time: 60
				})
			} else if (o.resCode == "301021") {
				alert("获取验证码过于频繁！")
			} else {
				alert(o.resMsg)
			}
			_this.util.scrollToTop();
			$("#btn_sendcmccode").removeAttr("disabled").html("获取短信验证码")
		}
	},
	setRing: function() {
		var _this = KGMO,
			data = [],
			_ringinfo = $("#ringinfo");
		if (_this.global.ringlist.detail.data.length > 0) {
			data = _this.global.ringlist.detail.data
		} else {
			data = _this.global.ringlist.data
		}
		for (var i = 0; i < data.length; i++) {
			if (data[i]["id"] == _this.global.ringlist.musicId) {
				if (data[i]['filename'] !== "") {
					_ringinfo.find(".r_songname").html(data[i]["filename"])
				}
				_ringinfo.find(".r_price").html(parseInt(parseInt(data[i]['price'], 10) / 100, 10));
				_ringinfo.find(".r_date").html(data[i]['data']);
				break
			}
		}
	},
	setRingInfoCB: function(o) {
		var _this = KGMO,
			_ringinfo = $("#ringinfo"),
			dateArr = [];
		if (o) {
			if (o.resCode == "000000") {
				if (o.singerName !== "") {
					_ringinfo.find(".r_songname").html(o.singerName + " - " + o.songName)
				} else {
					_ringinfo.find(".r_songname").html(o.songName)
				}
				_ringinfo.find(".r_price").html(parseInt(parseInt(o.price, 10) / 100, 10));
				_ringinfo.find(".r_date").html(o.crbtValidity)
			} else {
				_this.order.errCode({
					code: o.resCode
				})
			}
		}
	},
	buyOrderCB: function(o) {
		if (o) {
			if (o.resCode == "000000") {
				alert("订购成功！");
				KGMO.funs.goBack()
			} else {
				$(".btn_sendorder").html("完成订购");
				if (o.resCode.toString().length < 4) {
					alert(o.resMsg)
				} else {
					KGMO.order.errCode({
						code: o.resCode
					})
				}
			}
		}
		KGMO.order.isOrder = false
	},
	optRing: function(o) {
		var _this = KGMO;
		if (o) {
			var json = {},
				loadData = function(_o) {
					$.ajax({
						type: 'get',
						url: _o.url,
						dataType: _o.dataType,
						data: _o.metaData
					})
				};
			if (o.cmd == 1) {
				_this.order.setRing()
			} else if (o.cmd == 2) {
				if (o.check && $("#countdown").attr("disabled") == "disabled") {
					return
				}
				json = {
					dataType: 'jsonp',
					url: _this.order.url.sendCodeUrl,
					metaData: {
						mobile: _this.global.ringlist.mobile,
						cb: "KGMO.order.getRingCodeCB"
					}
				};
				_this.global.ringlist.sendMusicId = _this.global.ringlist.musicId;
				loadData(json)
			} else if (o.cmd == 3) {
				json = {
					dataType: 'jsonp',
					url: _this.order.url.checkMobileUrl,
					metaData: {
						mobile: o.mobile,
						cb: "KGMO.order.checkMobileCB"
					}
				};
				_this.global.ringlist.mobile = o.mobile;
				loadData(json)
			} else if (o.cmd == 4) {
				json = {
					dataType: 'jsonp',
					url: _this.order.url.buyOrderUrl,
					metaData: {
						pid: 5,
						validatecode: o.code,
						musicid: _this.global.ringlist.musicId,
						mobile: _this.global.ringlist.mobile,
						cb: "KGMO.order.buyOrderCB"
					}
				};
				loadData(json)
			}
		}
	},
	getRingInfo: function() {
		KGMO.order.optRing({
			cmd: 1
		})
	},
	sendOrder: function() {
		var _this = KGMO,
			code = $.trim($("#cmcmsgcode").val());
		if (code === "") {
			alert("请输入短信验证码！");
			_this.util.scrollToTop();
			return
		} else if (!(/^[0-9a-zA-Z]+$/.test(code))) {
			alert("短信验证码不正确！");
			_this.util.scrollToTop();
			return
		}
		if (!_this.order.isOrder) {
			_this.order.isOrder = true;
			$(".btn_sendorder").html("请稍后...");
			KGMO.order.optRing({
				cmd: 4,
				code: code
			})
		}
	},
	sendCmcCode: function() {
		var _this = KGMO,
			reg_p = "^1\\d{10}$",
			reg_n = "^((((13[5-9]{1})|(15[0,1,2,7,8,9]{1})|(188)){1}\\d{1})|((134[0-8]{1}){1})){1}\\d{7}$",
			phone = $.trim($("#cmcphone").val()),
			re = new RegExp(reg_p),
			re2 = new RegExp(reg_n);
		if (phone === "") {
			alert("请输入手机号！");
			_this.util.scrollToTop();
			return false
		} else if (!re.test(phone)) {
			alert("手机号格式不正确！");
			_this.util.scrollToTop();
			return false
		} else if (!re2.test(phone)) {
			alert("请输入中国移动手机号码！");
			_this.util.scrollToTop();
			return false
		}
		$("#btn_sendcmccode").attr("disabled", "true").html("正在获取验证码...");
		$(".btn_sendorder").html("完成订制");
		KGMO.order.optRing({
			cmd: 3,
			mobile: phone
		});
		return false
	},
	errCode: function(o) {
		if (o && o.code) {
			switch (o.code) {
			case "999000":
			case "999001":
			case "999002":
			case "999003":
			case "999004":
			case "999005":
			case "999006":
			case "999007":
			case "999008":
			case "999009":
			case "999010":
			case "999011":
			case "999012":
			case "999013":
			case "999014":
			case "999015":
			case "999016":
			case "999017":
			case "200001":
			case "200002":
			case "300001":
			case "300002":
			case "300003":
			case "167231":
			case "400001":
			case "400002":
			case "400003":
			case "400004":
				alert("系统繁忙，请稍后重试！");
				break;
			case "400000":
				alert("请输入中国移动手机号码！");
				break;
			case "999018":
			case "999019":
				alert("验证码错误");
				break;
			default:
				break
			}
			KGMO.util.scrollToTop()
		}
	}
};
KGMO.user = {
	info: {
		kugouid: null,
		kugouid: "",
		userpic: ""
	},
	clearLogin: function() {
		$("#uname,#pwd,#code,#r_uname,#r_pwd,#r_pwd2,#r_email").val("");
		KGMO.user.changeCode({
			t: $("#mlogin .code img").get(0)
		})
	},
	setUserInfo: function() {
		var _this = KGMO,
			_mod_collect = $("#mod_collect");
		_mod_collect.find(".hd img").attr("src", _this.user.info.userpic);
		_mod_collect.find(".hd h5").html(_this.user.info.kugouName)
	},
	checkLogin: function() {
		var _this = KGMO;
		_this.user.info.kugouid = _this.util.Cookie.read("KuGoo", "KugooID");
		_this.user.info.kugouName = unescape(_this.util.Cookie.read("KuGoo", "NickName"));
		_this.user.info.userpic = _this.util.Cookie.read("KuGoo", "Pic")
	},
	changeCode: function(o) {
		if (o) {
			var img = o.t.src.split("?")[0];
			o.t.src = img + "?" + Math.random()
		}
	},
	register: function() {
		var _this = KGMO,
			r_uname = $.trim($("#r_uname").val()),
			r_pwd = $.trim($("#r_pwd").val()),
			r_pwd2 = $.trim($("#r_pwd2").val()),
			r_email = $.trim($("#r_email").val()),
			mypwd = /[a-zA-Z0-9]+$/,
			myemail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,
			strLen = _this.util.getBytes({
				str: r_uname
			}),
			pwdLen = _this.util.getBytes({
				str: r_pwd
			});
		if (r_uname === "") {
			alert("请输入账号！");
			_this.util.scrollToTop();
			return false
		} else if (r_uname.length < 4 || r_uname.length > 80) {
			alert("请输入4-20位字符账号");
			_this.util.scrollToTop();
			return false
		} else if (r_pwd === "") {
			alert("请输入密码！");
			_this.util.scrollToTop();
			return false
		} else if (r_pwd.length < 6 || r_pwd.length > 16) {
			alert("密码长度在6-16位！");
			_this.util.scrollToTop();
			return false
		} else if (!mypwd.test(r_pwd)) {
			alert("密码只能包含字母或数字！");
			_this.util.scrollToTop();
			return false
		} else if (r_pwd2 != r_pwd) {
			alert("两次输入密码不一致！");
			_this.util.scrollToTop();
			return false
		} else if (r_email === "") {
			alert("请输入邮箱！");
			_this.util.scrollToTop();
			return false
		} else if (!myemail.test(r_email)) {
			alert("请输入正确的邮箱格式！");
			_this.util.scrollToTop();
			return false
		}
		$.ajax({
			type: 'get',
			url: _this.url.loginAndRegUrl,
			dataType: 'json',
			data: {
				"username": r_uname,
				"password": r_pwd,
				"email": r_email,
				"cmd": 401
			},
			async: false,
			success: function(res) {
				if (res && res["status"] == 1) {
					alert("注册成功！");
					_this.user.checkLogin();
					_this.user.setUserInfo();
					_this.user.alreadyLogin();
					_this.user.clearLogin();
					_this.util.scrollToTop();
					_this.funs.optMyCollect({
						cmd: 101
					})
				} else {
					if (res.error == "用户名称冲突") {
						alert("该名称已被注册！")
					} else {
						alert(res.error)
					}
					_this.util.scrollToTop()
				}
			},
			error: function(res) {
				alert(res.error);
				_this.util.scrollToTop()
			}
		});
		return false
	},
	login: function() {
		var _this = KGMO,
			uname = $.trim($("#uname").val()),
			pwd = $.trim($("#pwd").val()),
			code = $.trim($("#code").val());
		if (uname === "") {
			alert("请输入账号！");
			_this.util.scrollToTop();
			return false
		} else if (pwd === "") {
			alert("请输入密码！");
			_this.util.scrollToTop();
			return false
		} else if (code === "") {
			alert("请输入验证码！");
			_this.util.scrollToTop();
			return false
		}
		$.ajax({
			type: 'get',
			url: _this.url.loginAndRegUrl,
			dataType: 'json',
			async: false,
			data: {
				"captcha": code,
				"username": uname,
				"password": pwd,
				"cmd": 400
			},
			success: function(res) {
				if (res && res["status"] == 1) {
					alert("登录成功！");
					_this.user.checkLogin();
					_this.user.setUserInfo();
					_this.user.alreadyLogin();
					_this.user.clearLogin();
					_this.util.scrollToTop();
					_this.funs.optMyCollect({
						cmd: 101
					})
				} else {
					alert(res.error)
				}
			},
			error: function(res) {
				alert(res.error)
			}
		});
		return false
	},
	showReg: function() {
		var _mod_header = $("#mod_header");
		$("#searchtit").html("注册");
		$("#mod_collect").hide();
		$("#mlogin").hide();
		$("#nologin").hide();
		$("#mreg").show();
		$("#mod_login").show()
	},
	alreadyLogin: function() {
		$("#mod_login").hide();
		$("#mod_collect").show()
	},
	showLogin: function() {
		var _mod_header = $("#mod_header");
		$("#searchtit").html("登录");
		$("#mod_collect").hide();
		$("#mreg").hide();
		$("#nologin").hide();
		$("#mlogin").show();
		$("#mod_login").show()
	},
	logout: function() {
		var _this = KGMO;
		_this.util.Cookie.remove({
			name: "KuGoo",
			path: "/",
			domain: ".kugou.com"
		});
		_this.user.info.kugouid = null;
		_this.user.info.kugouName = "";
		_this.user.info.userpic = "";
		$("#mod_collect").hide();
		$("#mlogin").hide();
		$("#mreg").hide();
		$("#nologin").show();
		$("#mod_login").show()
	}
};
KGMO.api = {
	sdnSource: function() {
		var _this = KGMO,
			num = 0,
			req = _this.util.getRequest();
		if (req["fromid"] && (/^\d+$/.test(req["fromid"]))) {
			num = req["fromid"];
			(new Image()).src = "http://mobilelog.kugou.com/currentclick.php?type=1&cid=" + num + "&t=" + Math.random()
		}
	},
	ringOrder: function(o) {
		KGMO.funs.changeTab({
			tab: 131,
			musicId: o.musicId
		})
	},
	showCollectList: function(o) {
		KGMO.funs.changeTab({
			tab: 300,
			cid: o.id
		})
	},
	collect: function() {
		KGMO.funs.changeTab({
			tab: 3
		})
	},
	pause: function() {
		KGMO.player.pause()
	},
	search: function(o) {
		var keyword = "";
		if (o && o.keyword) {
			keyword = o.keyword
		} else {
			keyword = $("#keyword").val()
		}
		if (o.type) {
			if (keyword === "") {
				alert("关键字不能为空")
			}
		}
		keyword = $.trim(keyword);
		if (keyword !== "") {
			KGMO.funs.changeTab({
				tab: 4,
				keyword: keyword
			})
		}
		return false
	},
	showSingerTypeList: function(o) {
		KGMO.funs.changeTab({
			tab: 20,
			tid: o.tid
		})
	},
	showBangInfo: function(o) {
		var name = o.name || "";
		KGMO.funs.changeTab({
			tab: 100,
			cid: o.cid,
			name: unescape(name)
		})
	},
	showSingerInfo: function(o) {
		KGMO.funs.changeTab({
			tab: 200,
			singerid: o.singerid
		})
	},
	showPlayList: function(o) {
		var ctype = o.ctype || 1;
		KGMO.funs.changeTab({
			tab: 101,
			sid: o.sid,
			ctype: ctype
		})
	},
	downSong: function(o) {
		var _this = KGMO,
			kugouurl = "",
			filename = "",
			hash = o.hash,
			_pop_down = $("#pop_down");
		if (o.el) {
			filename = $(o.el).parent().find("span").html()
		} else {
			filename = o.filename || ""
		}
		if (!_this.util.isIOS()) {
			kugouurl = "kugou://start.weixin?filename=" + encodeURIComponent(filename) + "&hash=" + hash
		} else {
			kugouurl = "kugouurl://start.weixin?filename=" + encodeURIComponent(filename) + "&hash=" + hash
		}
		_pop_down.find(".btn_open").attr("href", kugouurl);
		KGMO.funs.popDown()
	},
	playFmSongs: function(o) {
		var _this = KGMO,
			songs = [],
			data = _this.global.fmlist.data,
			tmp = [];
		_this.player.isPlayRadio = true;
		_this.player.isPlayRing = false;
		_this.player.playMode = "order";
		$("#playmode").attr("class", "btn btn_order");
		if (o.fmid != _this.global.fmlist.detail.fmid) {
			_this.global.fmlist.detail.offset = '';
			_this.global.fmlist.detail.fmid = o.fmid
		}
		for (var i = 0, l = data; i < data.length; i++) {
			if (o.fmid == data[i]["fmid"]) {
				tmp = data[i]["fmSongData"][0]["songs"];
				break
			}
		}
		songs = _this.funs.formatFmSongs({
			songs: tmp,
			fmid: o.fmid
		});
		_this.player.getFmSongs();
		_this.player.addSongsPlay({
			songs: songs,
			playType: 103
		})
	},
	playRankSong: function(o) {
		$(".curplay").removeClass("curplay");
		KGMO.player.pause();
		switch (o.type) {
		case 1:
		case 4:
		case 100:
		case 101:
		case 200:
		case 300:
			KGMO.player.isPlayRadio = false;
			KGMO.player.isPlayRing = false;
			KGMO.player.setSongsPlay(o);
			break;
		case 13:
		case 130:
			KGMO.player.isPlayRadio = false;
			KGMO.player.isPlayRing = true;
			KGMO.player.setSongsPlay(o);
			break;
		default:
			break
		}
	},
	jumpTab: function() {
		var _this = KGMO,
			req = _this.util.getRequest(),
			tab = 0,
			keyword = "";
		if (req["tab"]) {
			tab = Number(req["tab"])
		}
		if (tab === 0 || tab == 1 || tab == 2 || tab == 3 || tab == 5 || tab == 10 || tab == 11 || tab == 12 || tab == 13) {
			_this.funs.changeTab({
				tab: tab
			})
		} else if (tab == 4) {
			if (req["keyword"] && $.trim(req["keyword"]) !== "") {
				keyword = decodeURIComponent($.trim(req["keyword"]));
				_this.funs.changeTab({
					tab: 4,
					keyword: keyword
				})
			} else {
				_this.funs.changeTab({
					tab: tab
				})
			}
		} else if (tab == 20) {
			if (req["id"]) {
				_this.funs.changeTab({
					tab: 20,
					tid: req["id"]
				})
			} else {
				_this.funs.changeTab({
					tab: 2
				})
			}
		} else if (tab == 101) {
			if (req["id"] && req["tid"]) {
				_this.funs.changeTab({
					tab: 101,
					sid: Number(req["id"]),
					ctype: Number(req["tid"])
				})
			} else {
				_this.funs.changeTab({
					tab: 11
				})
			}
		} else if (tab == 200) {
			if (req["id"]) {
				_this.funs.changeTab({
					tab: 200,
					singerid: Number(req["id"])
				})
			} else {
				_this.funs.changeTab({
					tab: 2
				})
			}
		} else if (tab == 100) {
			if (req["id"]) {
				_this.funs.changeTab({
					tab: 100,
					cid: Number(req["id"])
				})
			} else {
				_this.funs.changeTab({
					tab: 10
				})
			}
		} else {
			_this.funs.changeTab({
				tab: 0
			})
		}
	},
	bind: function() {
		$("#btn_back").on("click", function() {
			KGMO.funs.goBack()
		});
		$("#btn_search").on("click", function() {
			KGMO.funs.changeTab({
				tab: 4
			})
		});
		$("#btn_sub_search").on("click", function() {
			KGMO.api.search({
				type: true
			})
		});
		$("#search_tag").on("click", "a", function() {
			var keyword = $(this).html();
			keyword = $.trim(keyword);
			if (keyword !== "") {
				$("#keyword").val(keyword);
				KGMO.funs.changeTab({
					tab: 4,
					keyword: keyword
				})
			}
		});
		$("#search_result").on("click", "a", function() {
			var _this = this,
				json = {},
				data = $(_this).attr("data").split("|"),
				idx = $(_this).attr("idx");
			if (data.length == 4) {
				json = {
					"type": 4,
					"idx": idx
				};
				KGMO.api.playRankSong(json)
			}
		});
		$("#mod_nav").find("li").each(function() {
			$(this).on("click", function() {
				var o = {
					tab: parseInt($(this).attr("data-tab"), 10)
				};
				if (!$(this).hasClass("cur")) {
					KGMO.funs.changeTab(o)
				}
			})
		});
		$("#mod_subnav").find("li").each(function() {
			$(this).on("click", function() {
				var tab = parseInt($(this).attr("data-tab"), 10);
				KGMO.funs.changeTab({
					tab: tab
				})
			})
		});
		$("#playmode").on("click", function() {
			KGMO.player.changePlayMode()
		});
		$("#btn_play").on("click", function() {
			var _this = this,
				src = $("#" + KGMO.player.playerId).attr("src");
			if (src === "" || src == "about:blank") {
				return
			}
			if ($(_this).hasClass("btn_pause")) {
				KGMO.player.pause()
			} else {
				KGMO.player.play()
			}
		});
		$("#btn_next").on("click", function() {
			KGMO.player.playNextSong()
		});
		$(".mod_player").find(".singerhead,.songname").on("click", function() {
			KGMO.funs.changeTab({
				tab: 5
			})
		});
		$("#btn_mainplay").on("click", function() {
			var _this = this,
				src = $("#" + KGMO.player.playerId).attr("src");
			if (src === "" || src == "about:blank") {
				return
			}
			if ($(_this).hasClass("btn_pause")) {
				KGMO.player.pause()
			} else {
				KGMO.player.play()
			}
		});
		$("#btn_change").on("click", function() {
			var _el = $("#mod_mainplayer");
			if (KGMO.global.isCover) {
				_el.find(".lrc").show();
				_el.find(".cover").hide();
				_el.find(".btn_change").removeClass("btn_cover").addClass("btn_lrc");
				KGMO.global.isCover = false
			} else {
				_el.find(".lrc").hide();
				_el.find(".cover").show();
				_el.find(".btn_change").removeClass("btn_lrc").addClass("btn_cover");
				KGMO.global.isCover = true
			}
		});
		$("#mod_mainplayer").find(".btn_next").on("click", function() {
			KGMO.player.playNextSong()
		});
		$("#mod_mainplayer").find(".btn_prev").on("click", function() {
			KGMO.player.playPrevSong()
		});
		$("#btn_download").on("click", function() {
			if (KGMO.player.isPlayRing) {
				alert("彩铃不支持下载！");
				return
			} else if (KGMO.player.isPlayRadio) {
				alert("电台不支持下载！");
				return
			}
			var hash = $("#" + KGMO.player.fatherId).attr("hash"),
				filename = $("#songname").html();
			KGMO.api.downSong({
				hash: hash,
				filename: filename
			})
		});
		$("#bang_more").on("click", function() {
			KGMO.funs.changeTab({
				tab: 10
			})
		});
		$("#play_more").on("click", function() {
			KGMO.funs.changeTab({
				tab: 11
			})
		});
		$("#fm_more").on("click", function() {
			KGMO.funs.changeTab({
				tab: 12
			})
		});
		$("#ring_more").on("click", function() {
			KGMO.funs.changeTab({
				tab: 13
			})
		});
		$("#pop_bg").on("touchmove", function() {
			$("#pop_down").hide();
			$("#pop_base").hide();
			$("#pop_bg").removeClass("pop_bg_show").hide()
		});
		$("#pop_down").find(".close").on("click", function() {
			$("#pop_down").hide();
			$("#pop_bg").removeClass("pop_bg_show").hide()
		});
		$("#pop_base").find(".close").on("click", function() {
			$("#pop_base").hide();
			$("#pop_bg").removeClass("pop_bg_show").hide()
		});
		$("#btn_logout").on("click", function() {
			KGMO.user.logout()
		});
		$("#btn_login").on("click", function() {
			KGMO.user.showLogin()
		});
		$("#btn_reg").on("click", function() {
			KGMO.user.showReg()
		});
		setTimeout(function() {
			$(window).bind("scroll", function() {
				if (KGMO.util.isScrollBot()) {
					KGMO.funs.getList()
				}
				$(".pop_bg_show").css("height", $("html").height())
			})
		}, 1);
		$("body").bind("resize", function() {
			if (KGMO.util.isIOS()) {
				$("#top_fixed").fix({
					top: 0
				});
				$("#mod_player").fix({
					bottom: 0
				})
			}
			$(".wrap").css("padding-top", $("#top_fixed").height() + "px")
		})
	},
	init: function() {
		sdnClick(1248);
		KGMO.api.sdnSource();
		KGMO.util.scrollToTop();
		if (KGMO.util.isIOS()) {
			$("#top_fixed").fix({
				top: 0
			});
			$("#mod_player").fix({
				bottom: 0
			})
		}
		KGMO.player.init({
			fatherId: "player",
			playerId: "kugou"
		});
		KGMO.api.bind();
		KGMO.api.jumpTab();
		if (!KGMO.util.isCanPlayAudio()) {
			$("#songname").html("此款手机不支持HTML5播放")
		}
	}
};
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fc0eb0e71efad9184bda4158ff5385e91' type='text/javascript'%3E%3C/script%3E"));